Jump to content

what this error >>> PHP Notice: Undefined index, means????


poqoz-87

Recommended Posts

i m inserting user input into the ms sql database.

 

but there is an error which i need help to solve it. the error is this >> PHP Notice: Undefined index: Submit in C:\Inetpub\wwwroot\VisitorSurvey.php on line 38

 

can someone explain to me what does this error mean? n how do you solve it??

 

this are currently the codes that i m using

 

<body>

//this is the line that i m having error

if ($_POST['Submit'] == "Submit")

{

 

//Collect form data and assign to scalar variables

$Name = $_POST['Name'];

$Email = $_POST['Email'];

$Connection = $_POST['Connection'];

$Residence = $_POST['Residence'];

$Age = $_POST['Age'];

$Gender = $_POST['Gender'];

$Comments = $_POST['Comments'];

 

//Establish a connection to the Database

// create connection

$connection = mssql_connect("localhost","sa","sa");

 

// select database

$db = mssql_select_db("Hello", $connection);

 

//SQL Statement

$sql = "INSERT INTO Survey ".

"(Name,Email,Connection,Residence,Age,Gender,Comments) VALUES ('$Name', '$Email', '$Connection',

'$Residence', '$Age', '$Gender', '$Comments')";

 

//Execute SQL Statement and store results as a recordset

 

$rs = mssql_query($connection,$sql);

 

mssql_free_result($sql_result);

mssql_close($connection);

}

?>

<form action="" method="get">

<fieldset><legend>Name</legend>

<p>

  <label>

  <input type="text" name="Name" />

  </label>

</p>

</fieldset>

 

<fieldset><legend>Email</legend>

<p>

  <label>

  <input type="text" name="Email" />

  </label>

</p>

</fieldset>

 

<fieldset><legend>Web Connection</legend>

<p>

  <label>

  <select name="Connection">

  <option>OLEDB</option>

  </select>

  </label>

</p>

</fieldset>

 

<fieldset><legend>Residence (City/ST/Country)</legend>

<p>

  <label>

  <input type="text" name="Residence" />

  </label>

</p>

</fieldset>

 

<fieldset><legend>Age</legend>

<input name="Age" type="radio" value="" />Under 20

<input name="Age" type="radio" value="" />21-25

<input name="Age" type="radio" value="" />26-30

</fieldset>

 

<fieldset><legend>Gender</legend>

<input name="Gender" type="radio" value="" />Male

<input name="Gender" type="radio" value="" />Female

</fieldset>

 

<fieldset><legend>Comments</legend>

<p>

  <label>

  <input type="text" name="Comments" />

  </label>

</p>

</fieldset>

 

<input name="Submit" type="submit" onclick="MM_validateForm('Name','','R','Email','','RisEmail','Residence','','R','Comments','','R');return document.MM_returnValue" value="Submit" />

<input name="Reset" type="reset" value="Reset" />

 

 

</form>

</body>

Link to comment
Share on other sites

From my "limited" knowledge, this simply means that your using a variable before it is set.

 

If your php error reporting level is set to E_ALL or E_NOTICE you will get a bunch of these.

 

I have seen them pop up when trying to do something like

 

if(!isset($xyz)){
    echo 'xyz is not set, please try again';
}

 

just change the reporting level in the php.ini or use

 

error_reporting(E_WARNING);
ini_set('display_errors', '1');

 

at the top of your page and that should take care of it.

 

If someone else has a better solution, please post as I have been trying to find more info on this type of error for a while.

 

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.

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.