Jump to content

Notice: Undefined index


Recommended Posts

<form name=\"form1\" ACTION=\"$_SERVER[REQUEST_URI]\" METHOD=\"POST\">Your First Name<br><input name=\"first\" value = \"$first\" type=\"text\" id=\"first\" size=\"25\"><br><br>Last Name<br><input name=\"last\" value = \"$last\" type=\"text\" id=\"last\" size=\"25\"><br><br>Email<br><input name=\"email\" value = \"$email\" type=\"text\" id=\"email\" size=\"25\"><br><br>Telephone Number<br><input name=\"phone\" value = \"$phone\" type=\"text\" id=\"phone\" size=\"25\"><br><br><label for=\"comments\">Comments</label><textarea name=\"comments\" cols=\"18\" rows=\"4\" class=\"txt\" id=\"comments\"></textarea><div style=\"visibility:hidden\"><input name=\"email2\" type=\"text\" size=\"45\" id=\"email2\" > </div><input type=\"submit\" name=\"Submit\" value=\"Submit\" class=\"tpc4\"></form>\n";

Hi I am getting the error message  Notice: Undefined Index on the following form before submission

I would like to fix this rather than suppress errors

Any help would be much appreciated



Link to comment
Share on other sites

@FUNKAM35 - Does your page have multiple forms? If not, your $_POST variable should be "first" and not "first1"...unless there is more to your form that's not being shown.


To avoid errors being shown before a form is submitted, you could check if the form was submitted before using $_POST. However, you would still need to set variables like $first so that errors don't come up while the form is being displayed. Here's a quick example:

    $first = $_POST['first'];
    //get the rest of the form information
} else {
    $first = '';
    //initialize other variables...
//dispaly form...
Link to comment
Share on other sites

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.

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.