Wolverine68 Posted July 8, 2007 Share Posted July 8, 2007 I'm trying to create a basic form. The user fills in the information and submits. If all the required info is submitted, it gives a thank you message. If not, it gives an error stating what info needs to be submitted. I uploaded the php file to my web server. When trying to view the url via the web, it just give a blank white screen. Here's the coding: <html> <head> <title>Submitting a Form PHP</title> <style type="text/css"> .text { color: #000077; font-weight: bold;} </style> </head> <body bgcolor="#DDDDDD"> <? //Create function to display form when called function display_form() { //Create global variables global $fname; global $lname; global $email; global $age; $theForm=<<<EndForm <form action="$PHP_SELF" method="post"> <table> <tr><td><span class="text">Enter First Name:</span></td><td><input type="text" name="fname" size="20"></td></tr><br> <tr><td><span class="text">Enter Last Name:</span></td><td><input type="text" name="lname" size="20"></td></tr><br> <tr><td><span class="text">Enter E-mail Address:</span></td><td><input type="text" name="email" size="20"></td></tr><br> <tr><td><span class="text">Enter Age:</span></td><td><input type="text" name="age" size="20"></td></tr><br> <tr><td><input type="submit" value="Submit Information" name="submit"></td></tr> </table> </form> </body> </html> EndForm; return $theForm; } //check if this is the first time form is called if((!$fname) || (!$lname) || (!$email) || (!$age)) { print(display_form($theForm)); exit(); } //Check to make sure required info has been entered if((!$fname) || (!$lname) || (!$email) || (!$age)) { $message=<<<EndMessage <h2 align="center">Error- Your registration cannot be processed because some information was missing or incorrectly entered:</h2> EndMessage; //Display the error print($message); } //Show user what info was missing if(!$fname) { print("Your First name<br>"); } if(!$lname) { print("Your Last name<br>"); } if(!$email) { print("Your e-mail address<br>"); } if (strlen($email) < 7) { print("The e-mail address entered was only " . strlen($email) . " characters in length and needs to be at least 7<br>"); } if(!strpos($email, "@")) { print("Your e-mail address is missing the @ symbol<br>"); } if(!strpos($email, ".")) { print("Your e-mail address is missing the period<br>"); } if(!$age) { print("Your age<br>"); } if (!is_numeric($age)) { print("Your entry for age must be numeric<br>"); } //Redisplay the form { print(<b>"Please make the necessary corrections and resubmit:<br>"</b>); print(display_form($theForm)); } //If all the required info is in there, give a thank you message else { $message=<<<EndMessage <h2>Thank you $fname, your order should be processed within the next 24 hours</h2> EndMessage; print($message); } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
quickstopman Posted July 8, 2007 Share Posted July 8, 2007 i think your should do print(display_form()); instead of print(display_form($theForm)); because that variable is set in the function Quote Link to comment Share on other sites More sharing options...
Wolverine68 Posted July 8, 2007 Author Share Posted July 8, 2007 Thanks Quickstopman, but that didn't fix it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.