dksmarte Posted March 2, 2006 Share Posted March 2, 2006 I'm making a simple script to add a member to a website and I got some pretty interesting errors. First of all, here's the code:*removed because no longer relevant to solution*Here's the HTML form that submits to the above code:[code]<form action="addmember.php" action="post"> <table> <tr> <td>Username:</td> <td><input type="text" name="username" /></td> </tr> <tr> <td>MD5 Hash Of Password:</td> <td><input type="text" name="password" /></td> </tr> <tr> <td></td> <td><input type="submit" value="Add Member" /></td> </tr> </table> </form>[/code]I get this error when creating a new member with the above forum on php page:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Notice: Undefined index: username in c:\program files\easyphp1-8\www\haven\members\addmember.php on line 13Notice: Undefined index: password in c:\program files\easyphp1-8\www\haven\members\addmember.php on line 14[/quote]Now I know that I should check to make sure that the values of the script are never empty but I'm not too concerned with that since this script can only be accessed by administrators. Anyways, even when I submit data from the form so I know that the post array will have the indexes username and password defined, it still gives me that error. Shouldn't it be working? What am I missing? Quote Link to comment Share on other sites More sharing options...
trq Posted March 2, 2006 Share Posted March 2, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Now I know that I should check to make sure that the values of the script are never empty but I'm not too concerned with that[/quote]If you know you should do something, why dont you do it? If the form is posted empty then the indexes are never created. Quote Link to comment Share on other sites More sharing options...
dksmarte Posted March 2, 2006 Author Share Posted March 2, 2006 Nevermind. I realized what the problem was. I put action="addmember.php" and action="post" in the form tag. It should've been method="post".[!--quoteo(post=350850:date=Mar 1 2006, 09:03 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Mar 1 2006, 09:03 PM) [snapback]350850[/snapback][/div][div class=\'quotemain\'][!--quotec--]If you know you should do something, why dont you do it? If the form is posted empty then the indexes are never created.[/quote]Well I was purposefully submitting things so that I knew the indexes would be created. That's why I found the error so weird when I got it. No worries though, I found the problem in my form. Quote Link to comment Share on other sites More sharing options...
trq Posted March 2, 2006 Share Posted March 2, 2006 Still, its poor practice to not check these things are set before using them. Anyway..... up to you. 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.