taskhill Posted July 1, 2008 Share Posted July 1, 2008 Hello everyone, I am very new to php and have chosen to buy a book to learn this programming language. I have however created a script that I can't seem to get to work and was looking for some assistance. Since I probably will be spending a lot of time here I decided to post my first topic today. Can someone please tell me what is wrong with this remedial script. Everytime I try and access the page, it is returned completely blank. The link for the page is http://www.riverglenpatrol.com/register1.php and the code is as follows: <?php //Script 8.9 - register1.php //Address error handling ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE): //Set the title of the page and require the header template define ('TITLE', 'Register'); require ('header.html'); //Basic html formating stuff print '<div id="leftcontent"> <h1>Registration Form</h1> <p>Register so that you can take advantage of certain features like this, that, and the other thing.</p>'; //Check if the form has been submitted. if (isset ($_POST['submit'])){ //Create a flag variable $problem = FALSE; //Check for each value if (empty ($_POST['username'])){ $problem = TRUE; print '<p>Please enter a username!</p>'; } if (empty ($_POST['first_name'])){ $problem = TRUE; print '<p>Please enter your first name!</p>'; } if (empty ($_POST['last_name'])){ $problem = TRUE; print '<p>Please enter your last name!</p>'; } if (empty ($_POST['email'])){ $problem = TRUE; print '<p>Please enter your email address!</p>'; } if (empty ($_POST['password1'])){ $problem = TRUE; print '<p>Please enter a password!</p>'; } if ($_POST['password1'] != $_POST['password2']){ $problem = TRUE; print '<p>Your password did not match the confirmed password!</p>'; } if (!$problem){ print '<p>You are now registered!<br /> Okay, you are not really registered but...</p>'; }else{ print '<p>Please try again!</p>'; } } //Begin the html form print '<form action="register1.php" method="post"><p>'; //Create a sticky username input: print 'Username: <input type="text" name="username" size="30" value="' . $_POST['username'] . '" /><br />'; print 'First Name: <input type="text" name="first_name" size="30" value="' . $_POST['first_name'] . '" /><br /> Last Name: <input type="text" name="last_name" size="30" value="' . $_POST['last_name'] . '" /><br /> Email Address: <input type="text" name="email" size="30" value="' . $_POST['email'] . '" /><br />'; print 'Password: <input type="password" name="password1" size="20" /><br /> Confirm Password: <input type="password" name="password2" size="20" /><br /> <input type="submit" name="submit" value="Register!" /></p> </form>'; print '</div>'; //add the footer page require ('footer.html'); ?> Any and all help is greatly appreciated. Thanks in advance Task Link to comment https://forums.phpfreaks.com/topic/112843-just-learning-and-running-into-snags/ Share on other sites More sharing options...
lemmin Posted July 1, 2008 Share Posted July 1, 2008 If you make a file with just: <?php php_info(); ?> Does it print anything, or is it another blank page? Link to comment https://forums.phpfreaks.com/topic/112843-just-learning-and-running-into-snags/#findComment-579611 Share on other sites More sharing options...
taskhill Posted July 1, 2008 Author Share Posted July 1, 2008 I have done the php_info page. It is still up at http://www.riverglenpatrol.com/phpinfo.php When at the site the page is filled with all of the specifics. Thanks, Task Link to comment https://forums.phpfreaks.com/topic/112843-just-learning-and-running-into-snags/#findComment-579650 Share on other sites More sharing options...
lemmin Posted July 1, 2008 Share Posted July 1, 2008 All I can come up with is that your server is disallowing all error messages and, even though you are trying to turn them on, none are being displayed. Is the doctype that is in the generated source coming from the require("header.htm"); and require("footer.html"); lines? Or is that source different? Try removing those two and see if anything gets displayed. Link to comment https://forums.phpfreaks.com/topic/112843-just-learning-and-running-into-snags/#findComment-579655 Share on other sites More sharing options...
kenrbnsn Posted July 1, 2008 Share Posted July 1, 2008 In this line you have colon at the end: <?php error_reporting (E_ALL & ~E_NOTICE): ?> It needs to be a semi-colon: <?php error_reporting (E_ALL & ~E_NOTICE); ?> Ken Link to comment https://forums.phpfreaks.com/topic/112843-just-learning-and-running-into-snags/#findComment-579660 Share on other sites More sharing options...
taskhill Posted July 2, 2008 Author Share Posted July 2, 2008 I knew it would be something as stupid and simple as that. I bet you get that kind of stuff from beginers all the time, don't you. Thank you for picking up on it Ken. I had looked at the script so many times, I was looking right over it. Task Link to comment https://forums.phpfreaks.com/topic/112843-just-learning-and-running-into-snags/#findComment-579771 Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2008 Share Posted July 2, 2008 When learning PHP, developing php code, or debugging php code, turn on full php error reporting (set error_reporting to E_ALL (php.ini) or the equivalent numeric value (.htaccess) and set display_errors = On) in the master php.ini or in a .htaccess file to get php to help you. For the problem in this thread, a fatal parse error would have been generated. Turning on error reporting in the script has no effect in this case because the script is never executed. Also, you should only modify error reporting in a script for debugging purposes and should not normally set error_reporting/display_errors in a script as that will override any global settings you put in the php.ini or .htaccess file. Lastly, by eliminating E_NOTICE from the error_reporting setting, you are dooming your code to simple errors like typo's in variable names and turning off E_NOTICE messages on a live server will prevent the logging of errors generated by things like unexpected user input values (or hacking attempts) that you need to have a record of so that you can modify your code to validate or process correctly. Leave error_reporting set to E_ALL and only turn display_errors off on a live server to prevent the output of errors to the visitor but still log all errors. Link to comment https://forums.phpfreaks.com/topic/112843-just-learning-and-running-into-snags/#findComment-579949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.