dan09 Posted July 26, 2011 Share Posted July 26, 2011 I was following your excellent tutorial on how to create a user login in and register. The problem i have is when i load up the register.php file in the browser i get err messages like undefined index I have looked at other peoples comments but cannot fix this issue. Please can you help me? Thanks [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted July 26, 2011 Share Posted July 26, 2011 <?php echo "<h1>Register</h1>"; $submit = $_POST['submit']; if (isset($submit)) { $fullname = $_POST['fullname']; $username = $_POST['username']; $password = $_POST['password']; $repeatpassword = $_POST['repeatpassword']; echo "{$username}/{$password}/{$repeatpassword}/{$fullname}"; } ?> <html> <form action='/1/register.php' method='POST'> <table> <tr> <td> Your full name: </td> <td> <input type='text' name'fullname'> </td> </tr> <tr> <td> Choose a username: </td> <td> <input type='text' name'username'> </td> </tr> <tr> <td> Choose a Password: </td> <td> <input type='password' name'password'> </td> </tr> <tr> <td> Repeat password: </td> <td> <input type='password' name'repeatpassword'> </td> </tr> </table> <p> <input type='submit' name 'submit' value='Register'> </form> </html> this is most likely just a notice, and is triggered because you indices aren't being used until you submit the form...the best thing to do here is to check that the submit button has been set, then set your POST variables like I have don above Quote Link to comment Share on other sites More sharing options...
dan09 Posted July 26, 2011 Author Share Posted July 26, 2011 Thank you Quote Link to comment Share on other sites More sharing options...
dan09 Posted July 26, 2011 Author Share Posted July 26, 2011 I have a new error which is: Undefined index on line 4. I have had a look at line for but cannot understand why i have this error Can you help me thanks? [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted July 26, 2011 Share Posted July 26, 2011 the index notice refers to $submit = $_POST['submit'] this is only a notice and can really be ignored in this case..basically by setting it to a variable you are initializing the $_POST index without that index having a value since you havn't submitted the form...this will not effect your script whatsoever Quote Link to comment Share on other sites More sharing options...
dan09 Posted July 26, 2011 Author Share Posted July 26, 2011 Ok but when I test out the script and enter in data and i click submit nothing happens But isn’t all that data I just entered meant to be displayed for testing purposes Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted July 26, 2011 Share Posted July 26, 2011 make sure that your form action is sending your data to the right place...also you will want to add in <head> and >body> tags.. Quote Link to comment Share on other sites More sharing options...
dan09 Posted July 26, 2011 Author Share Posted July 26, 2011 I have done all of those things and still nothing is working I’m not sure what is going with this. Please can you help me find this problem and try to fix it? Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted July 26, 2011 Share Posted July 26, 2011 1. when you click submit...does it keep you on the same page? 2. do you have error_reporting set to E_ALL? If so, what errors do you receive in your error.log? ini_set("error_reporting",E_ALL); Quote Link to comment Share on other sites More sharing options...
dan09 Posted July 26, 2011 Author Share Posted July 26, 2011 1. when you click submit...does it keep you on the same page? 2. do you have error_reporting set to E_ALL? If so, what errors do you receive in your error.log? ini_set("error_reporting",E_ALL); 1) yes it does (register.php) 2) no i havent, where would i put this in the script? Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted July 26, 2011 Share Posted July 26, 2011 top of your php portion...okay so the action is correct.. if you want the errors to be displayed on your webpage instead of having to go to the error.log which you might even know where it is, put this as well on the top of you php code.. ini_set("display_errors","ON"); 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.