Jump to content

Recommended Posts

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 13

Notice: 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?
Link to comment
https://forums.phpfreaks.com/topic/3880-post-array-with-undefined-indexes/
Share on other sites

[!--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.
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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.