poqoz-87 Posted May 7, 2007 Share Posted May 7, 2007 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 https://forums.phpfreaks.com/topic/50327-what-this-error-php-notice-undefined-index-means/ Share on other sites More sharing options...
warewolfe Posted May 7, 2007 Share Posted May 7, 2007 have you tried assigning $_POST['Submit'] and echoing to see what is actually being sent? Link to comment https://forums.phpfreaks.com/topic/50327-what-this-error-php-notice-undefined-index-means/#findComment-247081 Share on other sites More sharing options...
poqoz-87 Posted May 7, 2007 Author Share Posted May 7, 2007 what do u mean? i dont understand. can give me the example of the code? Link to comment https://forums.phpfreaks.com/topic/50327-what-this-error-php-notice-undefined-index-means/#findComment-247088 Share on other sites More sharing options...
mmarif4u Posted May 7, 2007 Share Posted May 7, 2007 try this: if (isset($_POST['submit'])){do ur stuff} Link to comment https://forums.phpfreaks.com/topic/50327-what-this-error-php-notice-undefined-index-means/#findComment-247094 Share on other sites More sharing options...
poqoz-87 Posted May 7, 2007 Author Share Posted May 7, 2007 thanks people for the help! there are no more errors. but now, i cannot insert the user input into the ms sql database. Link to comment https://forums.phpfreaks.com/topic/50327-what-this-error-php-notice-undefined-index-means/#findComment-247104 Share on other sites More sharing options...
mmarif4u Posted May 7, 2007 Share Posted May 7, 2007 Sorry poqoz-87 for this: bcoz i did not work on ms sql, i can help with mysql. Wait, some other body will help out. Link to comment https://forums.phpfreaks.com/topic/50327-what-this-error-php-notice-undefined-index-means/#findComment-247106 Share on other sites More sharing options...
chronister Posted May 7, 2007 Share Posted May 7, 2007 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 https://forums.phpfreaks.com/topic/50327-what-this-error-php-notice-undefined-index-means/#findComment-247111 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.