HughbertD Posted March 12, 2008 Share Posted March 12, 2008 Hi all, I have a PHP page. What I am trying to do is open a <form> which has text boxes in, close that form, then open a different form, close that form, open the first <form> so that I can include the submit button. My hoping was that if i reference by name, the information would come through after the submit. However, I get nothing. Can I actually do this with forms? Code is below but it is quite lengthy Thanks for any help you can give Hugh <?php $usr = "root"; $pwd = "michael"; $db = "jostark"; $host = "localhost"; #connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } mysql_select_db("jostark", $cid); ?> <?php $id=$_GET[id];?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script language="javascript"> function toolbar(url) { newwindow=window.open(url,'name','height=325,width=600'); if (window.focus) {newwindow.focus()} } </script> <script language="JavaScript" src="../javascript/calendar3.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Bamboo : Placement Monitor</title> <script type="text/javascript" src="../add/tabpane/local/webfxlayout.js"></script> <link id="luna-tab-style-sheet" type="text/css" rel="stylesheet" href="../add/tabpane/css/luna/tab.css" disabled="disabled" /> <style type="text/css"> /* the bit that does the work */ body { margin:0; border:0; padding:0; height:100%; max-height:100%; background:#fff; font-family:arial, verdana, sans-serif; font-size:76%; overflow: hidden; margin-bottom: 10px; } /* for internet explorer */ * html body { padding:120px 0 50px 0; } * html #container { height:100%; width:100%; } * html #header {height:120px;} #footer { position:absolute; bottom:0; left:0; width:100%; height:45px; overflow:auto; text-align:right; background:#344E05; border-top:5px solid #507607; } * html #footer {height:50px;} /* end of bit that does the work */ h1 {font-size:4em; margin:0; padding:0;} #footer p { color:#CCF77D; margin:5px 10px 0 10px; } #header img { margin:8px 10px 10px 10px; } #container img {margin:5px;} #absolute { position:absolute; top:400px; right:100px; width:200px; background:#ddd; padding:10px; border:1px solid #000; } #left { float:left; background:#eee; padding:10px; border:1px solid #000; color:#000; width:50%; } #right { float:right; background:#ddd; padding:10px; border:1px solid #000; color:#000; } a:visited { font-size:1.1em; text-decoration:none; color:#ddd; } a:hover { color:#666666; text-decoration:none; } a:link { color:#808000; } .grey {color:#888;} .ltgrey {color:#ddd;} img#mascot {float:right;} #header ul { clear:both; text-align:center; border-top:1px solid #000000; } #header ul { margin:0; padding:0; list-style-type:none; background:transparent; height:1em; } #header ul li { display:inline; color:#000000; } .strike {text-decoration:line-through;} .lft {float:left;} .rgt{float:right;} .columnone, .columntwo {width:31%; float:left; text-align:justify; margin-right:2%;} .columnthree {text-align:justify; border:1px solid #fff;} * html .columnthree {border:0;} hr {clear:both; border:0; height:1px; color:#000000; background-color:#888;} .columnthree a, .columnthree a:visited {font-size:1em; color:#000; text-decoration:underline;} .columnthree a:hover {color:#888; text-decoration:none;} #header { position:absolute; top:0px; left:0px; width:100%; height:120px; overflow:auto; background:#283C04; border-bottom:4px solid #547C07; } #container { font-family:"verdana", serif; font-size: 0.9em; position:fixed; top:160px; left:0; bottom:50px; right:0; overflow:auto; background:#fff; padding:20px; text-align:center; color:#000000; } .style1 {color: #CCCCCC} </style> <script language="JavaScript" src="../javascript/calendar3.js"></script> <script type="text/javascript" src="../add/tabpane/js/tabpane.js"></script> </head> <body> <div id="header"> <div align="center"><img src="../img/bambooBannerTop.jpg" align="absmiddle" height="70" width="500" border="2"/></div> <ul> <li><a href="../index.html" title="AccessKey: 1" class="style1" accesskey="1">Home</a> | </li> <li><a href="../add/addData.php" title="AccessKey: a" accesskey="a">Add Data</a> | </li> <li><a href="http://localhost/joStark/css/display/displayData.php" title="AccessKey: b" accesskey="b">Display Data</a> | </li> <li><a href="../calendar/admin/calendar.php" title="AccessKey: c" accesskey="c">Manage Calendar</a> | </li> <li><a href="../export/export.php" title="AccessKey: d" accesskey="d">Export</a> | </li> <li><a href="../import/import.php" title="AccessKey: e" accesskey="e">Import</a> | </li> <li><a href="../help/help.php" title="AccessKey: f" accesskey="f">Help!</a> | </li> <li><a href="http://www.djduff.co.uk" title="AccessKey: h" accesskey="h">About the author</a></li> </ul> </div> <div id="footer"> <P align="right"><a href="javascript:toolbar('../toolbar/toolbar.php')"><img src="../img/cal.gif" border="0"/></a> <p align="right">Author: Hugh Downer | <a href="http://www.w3.org/Style/CSS/">CSS</a> | <a href="http://www.php.net">PHP</a> | <a href="http://www.mysql.com">MySQL</a></p> </div> <div id="container" align="center"> <?php # processed when form is submitted back onto itself if ($REQUEST_METHOD=="POST") { # setup SQL statement $SQL = " UPDATE student SET"; //$SQL = $SQL . " student.deptID = '$deptID', "; // $SQL = $SQL . " student.companyID = '$companyID', "; $SQL = $SQL . " student.firstName = '$firstName', "; $SQL = $SQL . " student.lastName = '$lastName', "; $SQL = $SQL . " student.otherName = '$otherName', "; $SQL = $SQL . " student.title = '$title', "; $SQL = $SQL . " student.houseNum = '$houseNum', "; $SQL = $SQL . " student.streetName = '$streetName', "; $SQL = $SQL . " student.postalTown = '$postalTown', "; $SQL = $SQL . " student.city = '$city', "; $SQL = $SQL . " student.postCode = '$postcode', "; $SQL = $SQL . " student.county = '$county', "; $SQL = $SQL . " student.country = '$country', "; $SQL = $SQL . " student.termHouseNum = '$termHouseNum', "; $SQL = $SQL . " student.termStreetName = '$ternStreetName', "; $SQL = $SQL . " student.termPostalTown = '$termPostalTown', "; $SQL = $SQL . " student.termCity = '$termCity', "; $SQL = $SQL . " student.termPostalCode = '$termPostCode', "; $SQL = $SQL . " student.termCounty = '$termCounty', "; $SQL = $SQL . " student.termCountry = '$termCountry', "; $SQL = $SQL . " student.phoneNum = '$phoneNum', "; $SQL = $SQL . " student.mobilePhoneNum = '$mobilePhoneNum', "; $SQL = $SQL . " student.termPhoneNum = '$termPhoneNum', "; $SQL = $SQL . " student.email = '$email', "; $SQL = $SQL . " student.termEmail = '$termEmail', "; $SQL = $SQL . " student.personalEmail = '$personalEmail', "; $SQL = $SQL . " student.dateOfBirth = '$dateOfBirth', "; $SQL = $SQL . " student.gender = '$gender', "; $SQL = $SQL . " student.facebook = '$facebook', "; $SQL = $SQL . " student.myspace = '$myspace',"; $SQL = $SQL . " student.homeWebsite = '$homeWebsite', "; $SQL = $SQL . " WHERE student.studentid = $id"; # execute SQL statement $result = mysql_query($SQL,$cid) or die (mysql_error()); # check for errors if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } echo ("<P><B> Link Updated</B></P>\n"); } else { //$id=$_POST['$id']; $id=$_GET[id]; //echo "the id is $id\n"; # display edit form (not post method) # setup SQL statement to retrieve link # that we want to edit $SQL = "select * from (student left join studentplacement on student.studentid=studentplacement.studentid) left join placement on studentplacement.companyID=placement.companyid where student.studentid=$id"; # SELECT * FROM student, placement, studentplacement WHERE student.studentID= $id and student.studentid = studentplacement.studentid and placement.companyID = studentplacement.companyID"; // $SQL = $SQL . " WHERE id = $id "; # execute SQL statement $ret = mysql_query($SQL,$cid) or die (mysql_error() . "\n$SQL\n"); # retrieve values $row = mysql_fetch_array($ret); $courseID=$row["courseID"]; $firstName = $row["firstName"]; $lastName = $row["lastName"]; $otherName = $row["otherName"]; $title = $row["title"]; $houseNum = $row["houseNum"]; $streetName = $row["streetName"]; $postalTown = $row["postalTown"]; $city = $row["city"]; $postCode = $row["postCode"]; $county = $row["county"]; $country = $row["country"]; $termHouseNum = $row["termHouseNum"]; $termStreetName = $row["termStreetName"]; $termPostalTown = $row["termPostalTown"]; $termCity = $row["termCity"]; $termPostCode = $row["termPostCode"]; $termCounty = $row["termCounty"]; $termCountry = $row["termCountry"]; $phoneNum = $row["phoneNum"]; $mobilePhoneNum = $row["mobilePhoneNum"]; $termPhoneNum = $row["termPhoneNum"]; $email = $row["email"]; $termEmail = $row["termEmail"]; $personalEmail = $row["personalEmail"]; $dateOfBirth = $row["dateOfBirth"]; $$gender = $row["gender"]; $facebook = $row["facebook"]; $myspace = $row["myspace"]; $homeWebsite = $row["homeWebsite"]; ?> <table align="center" width="75%"> <tr> <td align="left"><b>Create a new student</b></td> </tr> </table> <br /> <table align="center" width="75%"> <tr><td align="center"> <div class="tab-pane" id="tabPane1" align="center"> <script type="text/javascript"> tp1 = new WebFXTabPane( document.getElementById( "tabPane1" ) ); //tp1.setClassNameTag( "dynamic-tab-pane-control-luna" ); //alert( 0 ) </script> <div class="tab-page" id="tabPage1" align="center"> <h2 class="tab" align="center">Name</h2> <script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage1" ) );</script> <form name="fa" action="updateStud.php" id="fa" method="post"> <INPUT TYPE="hidden" NAME="id" VALUE="<?php echo("$id"); ?>"> <fieldset><legend><b>Name</b></legend> <table border="0" width="100%"> <th align="center"></th> <tr> <td width="10%"></td> <td width="10%"></td> <td width="10%" align="right">Firstname:</td><td width="15%"><input type="text" name="firstname" value="<?php echo ("$firstName"); ?>" /></td> <td width="5%"></td> <td width="10%" align="right">Lastname:</td><td width="15%"><input type="text" name="lastname" value="<?php echo ("$lastName"); ?>" /></td> <td width="25%"></td> </tr> <tr> <td width="10%"></td> <td width="10%"></td> <td width="10%" align="right">Other Name:</td><td width="15%"><input type="text" name="othername" value="<?php echo ("$otherName"); ?>" /></td> <td width="5%"></td> <td width="10%" align="right">Title:</td><td width="15%"><input type="text" name="title" value="<?php echo("$title");?>" /></td> <td width="25%"></td> </tr> </table> </fieldset> </div> <div class="tab-page" id="tabPage2" align="center"> <h2 class="tab" align="center">Addresses</h2> <script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage2" ) );</script> <fieldset> <legend><b>Home Address</b></legend> <table border="0" align="center"> <tr> <td width="10%"></td> <td width="20%" align="right">House Name or Number:</td><td width="15%"><input type="text" name="housenum" value="<?php echo("$houseNum"); ?>" /></td> <td width="7%" align="right">Street:</td><td width="15%"><input type="text" name="streetname" value="<?php echo("$streetName"); ?>" /></td> <td width="12%" align="right">Postal Town:</td><td width="15%"><input type="text" name="postaltown" value="<?php echo("$postalTown"); ?>" /></td> <td width="7%"></td> <td width="10%"></td> </tr> <tr> <td width="10%"></td> <td width="13%" align="right">City:</td><td width="15%"> <input type="text" name="city" value="<?php echo("$city"); ?>" /></td> <td width="7%" align="right">Postcode:</td> <td width="15%"><input type="text" name="postcode" value="<?php echo("$postCode"); ?>"/></td> <td width="7%" align="right">County:</td> <td width="15%"><input type="text" name="county" value="<?php echo("$county"); ?>" /></td> </tr> <tr> <td width="10%"></td> <td width="7" align="right">Country:</td> <td width="10%"><input type="text" name="country" value="<?php echo("$country"); ?>" /></td> </tr> </table> </fieldset> <br /> <br /> <fieldset> <legend><b>Term Time Address</b></legend> <table border="0" align="center" width="100%"> <tr> <td width="10%"></td> <td width="14%" align="right">House Name or Number:</td><td width="15%"><input type="text" name="termhousenum" value="<?php echo("$termHouseNum"); ?>" /></td> <td width="7%" align="right">Street:</td><td width="15%"><input type="text" name="termstreetname" value="<?php echo("$termStreetName"); ?>" /></td> <td width="7%" align="right">Postal Town:</td><td width="15%"><input type="text" name="termpostaltown" value="<?php echo("$termPostalTown"); ?>" /></td> <td width="7%"></td> <td width="10%"></td> </tr> <tr> <td width="10%"></td> <td width="13%" align="right">City:</td><td width="15%"> <input type="text" name="termcity" value="<?php echo("$termCity"); ?>"/></td> <td width="7%" align="right">Postcode:</td> <td width="15%"><input type="text" name="termpostcode" value="<?php echo("$termPostCode"); ?>" /></td> <td width="7%" align="right">County:</td> <td width="15%"><input type="text" name="termcounty" value="<?php echo("$termCounty"); ?>" /></td> </tr> <tr> <td width="10%"></td> <td width="7%" align="right">Country:</td> <td width="10%"><input type="text" name="termcountry" value="<?php echo("$termCountry");?>" /></td> </tr> </table> </fieldset> </div> <div class="tab-page" id="tabPage3" align="center"> <h2 class="tab" align="center">Contact</h2> <script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage3" ) );</script> <fieldset><legend><b>Phone Numbers</b></legend> <table border="0" align="center"> <tr> <td width="10%"></td> <td width="" align="right">Phone Number:</td><td width=""> <input type="text" name="phonenum" value="<?php echo("$phoneNum");?>" /></td> <td width="" align="right">Mobile Phone Number:</td><td width=""> <input type="text" name="mobilenum" value="<?php echo("$mobilePhoneNum"); ?>" /></td> <td width="" align="right">Term Time Phone Number:</td><td width=""> <input type="text" name="termphonenum" value="<?php echo("$termPhoneNum"); ?>" /></td> </tr> </table></fieldset> <fieldset><legend><b>E-Mail</b></legend> <table border="0" align="center"> <tr> <td width=""></td> <td width="" align="right">E-mail Address:</td><td width=""> <input type="text" name="email" value="<?php echo("$email"); ?>" /></td> <td width="" align="right">Term Email Address:</td><td width=""> <input type="text" name="termemail" value="<?php echo("$termEmail"); ?>" /></td> <td width="" align="right">Personal e-mail:</td><td width=""> <input type="text" name="personalemail" value="<?php echo("$termPhoneNum"); ?>" /></td> </tr> </table> </fieldset> <fieldset><legend><b>Social Networks</b></legend> <table border="0" align="center"> <tr> <td width=""></td> <td width="" align="right">Facebook:</td><td width=""> <input type="text" name="facebook" value="<?php echo("$facebook");?>" /></td> <td width="" align="right">Myspace:</td><td width=""> <input type="text" name="myspace" value="<?php echo("$myspace");?>"/></td> <td width="" align="right">Home website:</td><td width=""> <input type="text" name="homewebsite" value="<?php echo("$homeWebsite");?>" /></td> </tr> </table> </fieldset> </form> </div> <div class="tab-page" id="tabPage5" align="center"> <h2 class="tab" align="center">Placement</h2> <fieldset><legend><B>Placement</B></legend> <?php $usr = "root"; $pwd = "michael"; $db = "jostark"; $host = "localhost"; $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } mysql_select_db("jostark", $cid); $SQL = "select current_date"; $retid = mysql_query($SQL, $cid); if (!$retid) { echo( mysql_error()); } else { while ($row = mysql_fetch_array($retid)) { $currentDate = $row["current_date"]; $task = $_GET['task']; if ($task=="del") { $id = $_GET[id]; $compid = $_GET[compid]; $SQL = " DELETE FROM studentplacement "; $SQL = $SQL . " WHERE studentID = $id and companyID = $compid "; mysql_query($SQL, $cid) or die (mysql_error()); } } } ?> <form name="tstest" action="insertStudPlacement.php" method="post"> <INPUT TYPE="hidden" NAME="id" VALUE="<?php echo("$id"); ?>"> <?php $SQL = "select * from student, placement, studentplacement where student.studentid = studentplacement.studentid and placement.companyID = studentplacement.companyID and student.courseID=course.courseID and studentplacement.studentID = '$_GET[id]'"; # retrieve values $row = mysql_fetch_array($ret); $retid = mysql_query($SQL, $cid); if (!$retid) { echo( mysql_error()); } else { echo "<P><TABLE CELLPADDING=4 align=center >\n";?> <tr> <td bgcolor="#FFFFFF" align="center"><b>Company</b></td> <td bgcolor="#FFFFFF"align="center"><b>Start Date</b></td> <td bgcolor="#FFFFFF" align="center"><b>End Date</b></td> </tr> <?php while ($row = mysql_fetch_array($retid)) { $compName = $row["compName"]; $compCity = $row["compCity"]; $compCountry = $row["compCountry"]; $email = $row["email"]; $compid = $row["companyID"]; $startdate = $row["start"]; $enddate = $row["end"]; if ($currentDate > $startdate && $currentDate < $enddate) { $bg = "#82A4FD"; } else { $bg = "#E6FBBD"; } $ConvertedStartDate = date("F jS, Y", strtotime($startdate)); //echo $ConvertedStartDate; $ConvertedEndDate = date("F jS, Y", strtotime($enddate)); ?> <TR bgcolor="<?php echo ("$bg");?>"> <?php echo ("<TD>$compName $compCity, $compCountry</TD>\n");?> <TD align=center><?php echo ($ConvertedStartDate);?></TD> <?php echo ("<TD align=center>$ConvertedEndDate</TD>\n"); echo ("<TD><A HREF=\"studentEdit.php?id=$id&task=del&compid=$compid\">Delete</A></TD>"); echo ("</TR>"); } echo ("</TABLE>"); } ?> <br /> <table border="0" align="center"> <tr> <td align="center"><b>Add another placement</b></td> </tr> <tr> <td> <?php $id=$_GET[id]; //connect to MySQL $connect = mysql_connect("localhost","root","michael") or die ("Could not connect to database."); //choose the database mysql_select_db("jostark"); //get data from database $query = mysql_query("SELECT `companyID`,`compName`, `compCity`, `compCountry` FROM `placement` ORDER BY `companyID` ASC") or die (mysql_error()); echo "<select name='placement'>\n"; while ($data = mysql_fetch_array($query, MYSQL_ASSOC)) { echo "<option value='{$data['companyID']}'6>{$data['compName']}, {$data['compCity']}, {$data['compCountry']}</option>\n"; } echo "</select>\n"; ?> </td> </tr> </table> <br /> <table border="0" align="center"> <tr> <td align="center"><b>Start Date</b></td> <td></td> <td align="center"><b>End Date</b></td> </tr> <tr> <td><input type="Text" name="startdate" value=""></td> <td><a href="javascript:cal5.popup();"><img src="../img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a></td> <td><input type="Text" name="enddate" value=""></td> <td><a href="javascript:cal6.popup();"><img src="../img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a></td> </tr> </table> <br /> <table align="center"> <tr> <td align="center" valign="bottom"><input type="submit" value="Add Placement"/></td> </tr> <tr> <td align="center" height="60px" valign="bottom">Company not Listed?</td> </tr> <tr> <td align="center"><a href="javascript: void(0)" onMouseUp="window.opener.location.href='addPlacement.php'">Add new placement</a></td> </tr> <tr> <td align="center" height="70px" valign="bottom"></td> </tr> </table> </form> <script language="JavaScript"> var cal5 = new calendar3(document.forms['tstest'].elements['startdate']); cal5.year_scroll = true; // year scrolling is enabled here cal5.time_comp = false; //time display is disable var cal6 = new calendar3(document.forms['tstest'].elements['enddate']); cal5.year_scroll = true; // year scrolling is enabled here cal5.time_comp = false; //time display is disable </script> </fieldset> </div> <div class="tab-page" id="tabPage6" align="center"> <h2 class="tab" align="center">Course</h2> <fieldset><legend><b>Select Course</b></legend> <table align="left"> <tr> <TD align="left"> <form action="updateStud.php" method="post" name="fa" id="fa"> <?php $SQL = "select * from (student left join studentplacement on student.studentid=studentplacement.studentid) left join placement on studentplacement.companyID=placement.companyid where student.studentid=$id"; $ret = mysql_query($SQL,$cid) or die (mysql_error() . "\n$SQL\n"); $row = mysql_fetch_array($ret); $courseID=$row["courseID"]; $sql2 = "SELECT `courseID`, `courseName` from course ORDER BY `courseName` ASC"; if ( !$result = mysql_query($sql2) ) { echo ('Database error: ' . mysql_error()); } else { $school_select = "<select name=\"courseID\">\n"; while( $data = mysql_fetch_array($result) ) { $selected = ($courseID == $data['courseID']) ? " SELECTED" : ""; $school_select .= "<option value=\"".$data['courseID']."\"".$selected.">".$data['courseName']."</option>\n"; } $school_select .= "</select>\n"; } echo ($school_select); ?> <td><a href="../add/addCourse.php">Can't find Course? Add a new one</a></td> </tr> </table> </fieldset> </div> <br /> <table border="0" width="100%"> <tr> <td align="right"> <input type="submit" align="right" value="Create Student" /> </form> </td> </tr> </table> <br /> </form> <script language="JavaScript"> var cal5 = new calendar3(document.forms['tstest'].elements['startdate']); cal5.year_scroll = true; // year scrolling is enabled here cal5.time_comp = false; //time display is disable var cal6 = new calendar3(document.forms['tstest'].elements['enddate']); cal5.year_scroll = true; // year scrolling is enabled here cal5.time_comp = false; //time display is disable </script> </div> </div> <script type="text/javascript"> //<![CDATA[ setupAllTabs(); //]]> </script> <hr /> </td> </tr> </table> <?php } ?> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/95820-what-i-can-and-cant-do/ Share on other sites More sharing options...
haku Posted March 12, 2008 Share Posted March 12, 2008 Before I go through that mountain of code, can you explain that a little more? What does the first table do? What does the second table do? Why do you want to close the first table and open the second one? Why do you want to close the second table and reopen the first one? And what is the problem at the moment? Quote Link to comment https://forums.phpfreaks.com/topic/95820-what-i-can-and-cant-do/#findComment-490548 Share on other sites More sharing options...
HughbertD Posted March 12, 2008 Author Share Posted March 12, 2008 Ok, apologies for being very lazy. I have a mySQL database holding information on students. The page itself, echos all the information from the db into the textboxes, and has a submit button at the very end of the page which sends the info to an update.php script which uses $_POST[values] to update the db. However, one <form> is referring to a different table in the database. Due to the design of the page it is halfway through my first form. I want the two forms to do two things. I thought that by doing; <form name=1> ...textboxes etc... </form> <form name=2> ..textboxes plus submit button... </form> <form name=1> ..the forms submit button... </form> I could get around it, but my $_POSTs dont pick up anything Thank for taking the time to help Hugh Quote Link to comment https://forums.phpfreaks.com/topic/95820-what-i-can-and-cant-do/#findComment-490562 Share on other sites More sharing options...
haku Posted March 12, 2008 Share Posted March 12, 2008 When you create form elements you give them names, allowing you to access the information entered into them when you are processing the form. Since the only time you are interacting with the database is when the form is being processed, you should be able to just take in all the information in one form, then separate it into the two data sets (one for each table in the database) that they need to go into. For example: <form action="some_page.php" method="post"> <input type="text" name="first_name" /> <input type="text" name="age" /> <input type="text" name="last_name" /> <input type="submit" value="submit" /> </form> Now lets imagine that you want to put the data entered into 'first_name' and 'last_name' into 'table1' in your database and the data entered into 'last_name' into 'table2' in your database. This basically mimics what you were speaking of - data in the surrounding form (in this case first name nad last name) goes into one table, data in the inner form (in this case age) goes to another table. So when you process it you go like this: <?php $first_name = $_POST['first_name']; $age = $_POST['age']; $last_name = $_POST['last_name']; mysql_query("INSERT INTO table1 (first_name, last_name) VALUES ('" . $first_name . "', '" . $last_name . "')"); mysql_query("INSERT INTO table2 (age) VALUES ('" . $age . "')"); In this way you separate the values when you process them and put them in the applicable tables. Quote Link to comment https://forums.phpfreaks.com/topic/95820-what-i-can-and-cant-do/#findComment-490583 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.