Jump to content

cleme1q

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cleme1q's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Is there a way to take variables that are assigned in one form and pass them to another form, i.e. Can the value of $form1value be passed to form2 so when I click submit, that data is available to be passed to submit_data.php <form name=x method=post> $form1value=mysql_query(xyz); </form> <form name=form2 action=submit_data.php method=post> question? <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> <input type="submit"/>
  2. 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>
  3. 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); ?>
  4. 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>
  5. In the bottom left hand corner of the page it has a button to allow me to MARK SOLVED.
  6. Thanks very much. It works now. I am new to programming in general and php in particular. I will try to use correct format when posting questions.
  7. Hi, I have a case where I have 2 Drop Downs that are populated by a db query. When a choice is made in the first drop down, the page refreshes and the second drop down is correctly populated using the input from the first drop down. My problem is that when the page refreshes, the first drop down also refreshes so it no longer shows the selected option and goes back to a default setting. How can I have it show the selected setting on refresh. Here is the relevant snippet: <script language="JavaScript"> function autoSubmit() { var formObject = document.forms['CommentsForm']; formObject.submit(); } </script> <Select name=district onChange="autoSubmit();"> <option>Choose District</option> <?php //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=$row["district"]; $options_d.="<option value=\"$district\">".$district.'</option>'; } ?> <?php echo "$options_d" ?> </select> <br><br> <Select name="school_name_box"> <option value=0>Choose School <?php if(isset($_GET["district"])) { $district_selection = $_GET["district"]; } //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"]; $options.="<option value=\"$tag\">".$school.'</option>'; } ?> <?php echo "$options" ?> </select>
×
×
  • 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.