cleme1q Posted February 22, 2010 Share Posted February 22, 2010 Hi, I am trying to submit data from a form and call a submit_data.php file. However, there seems to be something wrong with the syntax of my code. Any help is appreciated. Thanks <html> <body> <form action="submit_data.php" method="post"> question 1? <input type="radio" name="q1" value="Y" /> Yes <input type="radio" name="q1" value="N" /> No <input type="radio" name="q1" value="M" /> I'm not Sure<br><br> question 2? <input type="radio" name="q2" value="Y" /> Yes <input type="radio" name="q2" value="N" /> No <input type="radio" name="q2" value="M" /> I'm not Sure<br><br> question 3? <input type="radio" name="q3" value="Y" /> Yes <input type="radio" name="q3" value="N" /> No <input type="radio" name="q3" value="M" /> I'm not Sure<br><br> question 4? <input type="radio" name="q4" value="Y" /> Yes <input type="radio" name="q4" value="N" /> No <input type="radio" name="q4" value="M" /> I'm not Sure<br><br> question 5? <input type="radio" name="q5" value="Y" /> Yes <input type="radio" name="q5" value="N" /> No <input type="radio" name="q5" value="M" /> I'm not Sure<br><br> comment: <br><style type="text/css"> textarea.html-text-box {background-color:ffffff;background-image:url(http://);background-repeat:no-repeat;background-attachment:fixed;border-width:1;border-style:solid;border-color:cccccc;font-family:Arial;font-size:10pt;color:000000;} input.html-text-box {background-color:ffffff;font-family:Arial;font-size:10pt;color:000000;} </style> <textarea name="comments" cols="60" rows="15" class="html-text-box"></textarea><br> <input type="submit"/><input type="reset" value="Reset Screen"/><p style="font-family:verdana,arial,sans-serif;font-size:10px;color:999999;"></p> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
ialsoagree Posted February 22, 2010 Share Posted February 22, 2010 There doesn't appear to be anything wrong with the HTML. Make sure that the form action has the correct URL. If it does, we need more information (specifically, the PHP code that's suppose to run). Quote Link to comment Share on other sites More sharing options...
sader Posted February 22, 2010 Share Posted February 22, 2010 how looks submit_data.php ? Quote Link to comment Share on other sites More sharing options...
cleme1q Posted February 22, 2010 Author Share Posted February 22, 2010 Here is the php from submit_data.php <?php //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } ?> <?php $pq1=$_POST["q1"]; $pq2=$_POST["q2"]; $pq3=$_POST["q3"]; $pq4=$_POST["q4"]; $pq5=$_POST["q5"]; $pq6=$_POST["comments"]; $submit_query = ("INSERT INTO xx.`xx` (`q1`, `q2`, `q3`, `q4`,`q5`,`comments`) VALUES ('$pq1','$pq2','$pq3','$pq4','$pq5','$pq6')"); echo "$submit_query"; mysql_query($submit_query); ?> Quote Link to comment Share on other sites More sharing options...
86Stang Posted February 22, 2010 Share Posted February 22, 2010 And what is the exact error message you're getting and on which page is said error being shown? Quote Link to comment Share on other sites More sharing options...
cleme1q Posted February 22, 2010 Author Share Posted February 22, 2010 The screen just refreshes and and all the are cleared away. within the page that has the html I also get some info from a db that i will use to populate the submit_data.php, but have not gotten there yet. could this code be causing a problem? <script language="JavaScript"> function autoSubmit() { var formObject = document.forms['AddCommentsForm']; formObject.submit(); } </script> <form name="AddCommentsForm" method="get"> <?php //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } ?> <br><br><br><br><br> <Select name=district_box onChange="autoSubmit();"> <option>Choose District</option> <?php $district_selection = isset($_GET["district_box"]) ? $_GET["district_box"] : false; //Select School district you want info on $district_query="select distinct district from school order by district"; $district_result=mysql_query($district_query); //$options_d=""; //*** loop over the results ***/ while ($row=mysql_fetch_array($district_result)) { $district_s=$row["district"]; $selected = $district_selection == $district_s ? 'selected': ''; $options_d.="<option value=\"$district_s\" $selected>".$district_s.'</option>'; } ?> <?php echo "$options_d" ?> </select> <br><br> <Select name=school_name_box onChange="autoSubmit();"> <option value=0>Choose School <?php $school_selection = isset($_GET["school_name_box"]) ? $_GET["school_name_box"] : false; //Select School you want info on $school_query="select school_tag,school_name from school where district = \"$district_selection\" order by school_name"; $school_result=mysql_query($school_query); $options=""; //*** loop over the results ***/ while ($row=mysql_fetch_array($school_result)) { $tag=$row["school_tag"]; $school=$row["school_name"]; $selected = $school_selection == $tag ? 'selected': ''; $options.="<option value=\"$tag\" $selected>".$school.'</option>'; } ?> <?php echo "$options" ?> </select> <br><br> <Select name=teacher_name_box onChange="autoSubmit();"> <option value=0>Choose Teacher <?php $teacher_selection = isset($_GET["teacher_name_box"]) ? $_GET["teacher_name_box"] : false; //Select Teacher you want info on $teacher_query="select teacher_tag,teacher_last_name, teacher_first_name from teacher where school_tag = \"$school_selection\" order by teacher_last_name asc"; $teacher_result=mysql_query($teacher_query); $options=""; //*** loop over the results ***/ while ($row=mysql_fetch_array($teacher_result)) { $teacher_tag=$row["teacher_tag"]; $TeacherLN=$row["teacher_last_name"]; $TeacherFN=$row["teacher_first_name"]; $selected = $teacher_selection == $teacher_tag ? 'selected': ''; $options_t.="<option value=\"$teacher_tag\" $selected>".$TeacherLN.', '.$TeacherFN.'</option>'; } ?> <?php echo "$options_t" ?> </select> <br><br> <Select name=subject_name_box onChange="autoSubmit();"> <option value=0>Choose Subject <?php $subject_selection = isset($_GET["subject_name_box"]) ? $_GET["subject_name_box"] : false; //Select Subject $subject_query="select subject_tag,subject from subject order by subject asc"; $subject_result=mysql_query($subject_query); $options=""; //*** loop over the results ***/ while ($row=mysql_fetch_array($subject_result)) { $subject_tag=$row["subject_tag"]; $subject_name=$row["subject"]; $selected = $subject_selection == $subject_tag ? 'selected': ''; $options_s.="<option value=\"$subject_tag\" $selected>".$subject_name.'</option>'; } ?> <?php echo "$options_s" ?> </select> <br><br> 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.