homepage Welcome to WebmasterWorld Guest from 54.197.94.241
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Error in Forms Script
I get blank page in browser
Senmar50




msg:1297877
 7:59 am on Sep 14, 2005 (gmt 0)

Hi All,

Can someone look at my script and let me know where the error is. It was working. I deleted one of the brackets "}", and now it doesn't work. I can't remember which line I deleted it from.

<?php

// Check name and strip any slashes:

if (strlen($name) > 0) {
$name = stripslashes($name);
} else {
// If no name was entered...
$name = NULL;
echo '<p><b>You forgot to enter your name!</b></p>';
}
// Check $comments and strip any slashes:

if (strlen($comments) > 0) {
$comments = stripslashes($comments);
} else {
// If there are no comments...
$comments = NULL;
echo '<p><b>You forgot to enter your comments!</b></p>';
}

// Check $email:

if (!(strlen($email) > 0) ) {
$email = NULL;
echo '<p><b>You forgot to enter your email!</b></p>';
}

// Gender...

if (isset($gender)) {

if ($gender == 'M') {
$message = '<b><p>Good day, Sir!</p></b>';

} elseif ($gender == 'F') {
$message = '<b><p>Good day, Madam!</p></b>';
} else {

// If no gender was selected...

$gender = NULL;
echo '<p><b>You forgot to enter your gender!</b></p>';
}
// If everything was filled out, print the message.

if ($name && $comments && $email && $gender) {
echo "Thank you, <b>$name</b> for the following comments:<br /><tt>$comments</tt><p>We will reply to you at <i>$email</i>.</p>";

echo $message;
}

?>
<html>
<form action="" method="">
<fieldset>
<legend>Enter your information in the form below:</legend>

<p><b>Name:</b> <input type="text" name="name" size="20" maxlength="40" /></p>
<p><b>Email Address:</b> <input type="text" name=email" size="40" maxlength="60" /></p>
<p><b>Gender:</b> <input type="radio" name="gender" value="M" />Male <input type="radio" name="gender" value="F" />Female</p>
<p><b>Age:</b>
<select name="age">
<option value="0 - 30">Under 30</option>
<option value="30 - 60">Between 30 and 60</option>
<option value="60+">Over 60</option>
</select></p>

<p><b>Comments:</b>
<textarea name="comments" rows="3" cols="50"></textarea></p>
</fieldset>
<div align="center"><input type="submit" name="submit" value="Submit Information" />
</div>

</form>

 

Senmar50




msg:1297878
 10:07 am on Sep 14, 2005 (gmt 0)

I FOUND IT!

isset() { didn't have it's closing bracket }

// Gender...

if (isset($gender)) {

if ($gender == 'M') {
$message = '<b><p>Good day, Sir!</p></b>';}

elseif ($gender == 'F') {
$message = '<b><p>Good day, Madam!</p></b>';
} else {

// If no gender was selected...

$gender = NULL;
echo '<p><b>You forgot to enter your gender!</b></p>';
}

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved