louneas Posted April 25, 2012 Share Posted April 25, 2012 Hye there im branded new in php here. Im trying to develop a system based on php and mysql. I have 20 fields on my database table. Im trying to separate fields into 2 forms which is each form contain 10 fields - form_1.php(contain 10 fields) -form_2.php(contain 10 fields) form_1.php and form_2.php is connected each other which is user have to insert data in the form_1.php and then there are NEXT button that will bring user to form_2.php.In the form_2.php there will be a SUBMIT button which send data to database. Im trying to do but i cannot go through can someone show me any way to ?? Quote Link to comment https://forums.phpfreaks.com/topic/261568-newbie-question/ Share on other sites More sharing options...
thara Posted April 25, 2012 Share Posted April 25, 2012 use session to store validate data and then send session values to the database... Quote Link to comment https://forums.phpfreaks.com/topic/261568-newbie-question/#findComment-1340341 Share on other sites More sharing options...
trq Posted April 25, 2012 Share Posted April 25, 2012 Or, a simpler option is simply to post the data from form_1 to form_2 and store it within hidden form elements ready to be sent again along with the rest of the data to the final page for processing. Quote Link to comment https://forums.phpfreaks.com/topic/261568-newbie-question/#findComment-1340354 Share on other sites More sharing options...
louneas Posted April 25, 2012 Author Share Posted April 25, 2012 This is my coding form_A.php <!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> </head> <body> <h3 align="center">APPLICATION DETAILS</h3> <form action="form_B.php" method="post"> <table width="95%" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="15%"><div align="left"> Name:</div></td> <td width="32%"><input type="text" name="Name" size="45"></td> <td width="9%">Gender:</td> <td width="44%"><input type="text" name="Gender" size="20"></td> </tr> <tr> <td><div align="left"> ID Number: </div></td> <td><input type="text" name="ID" size="25"></td> <td>Ages:</td> <td><input type="text" name="Age" size="20"></td> </tr> <tr> <td height="56">Address:</td> <td><textarea name="Address" id="Address" cols="45" rows="5"></textarea></td> <td>State:</td> <td><select name="State" id="select"> <option value="Pahang">Pahang</option> <option value="Perak">Perak</option> <option value="Selangor">Selangor</option> </select> </td> </tr> <tr> <td>Occupation:</td> <td><input type="text" name="Occupation"></td> <td>Monthly Salary</td> <td><input type="text" name="Salary"></td> </tr> <tr> <td>Race:</td> <td><input type="text" name="Race"></td> <td>Nationality:</td> <td><select name="Nationality" id="Nationality"> <option value="Nationality">Nationality</option> <option value="Not Nationality">Not Nationality</option> </select> </td> </tr> <tr> <td>Status :</td> <td><select name="Status" id="Status"> <option value="Single">Single</option> <option value="Married">Married</option> <option value="Divorce">Divorce</option> </select> </td> <td> </td> <td> </td> </tr> </table> <p align="center"><br> </br> <br> <input type="submit" name="button" id="button" value="NEXT" /> </br> </form> </body> </html> And this is form_B.php <!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> </head> <body> <h3 align="center">FATHER DETAILS</h3> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <table width="95%" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="15%">Father Name </div></td> <td width="32%"><input type="text" name="FatherName" size="45"></td> <td width="9%">Phone Number:</td> <td width="44%"><input type="text" name="FatherNumber" size="20" id="FatherNumber"></td> </tr> <tr> <td><div align="left"> Father ID Number: </div></td> <td><input type="text" name="FatherID" size="25"></td> <td>Ages:</td> <td><input type="text" name="FatherAge" size="20"></td> </tr> <tr> <td height="56">Address:</td> <td><textarea name="FatherAddress" id="FatherAddress" cols="45" rows="5"></textarea></td> <td>State:</td> <td><select name="FatherState" id="select"> <option value="Pahang">Pahang</option> <option value="Perak">Perak</option> <option value="Selangor">Selangor</option> </select> </td> </tr> <tr> <td>Occupation:</td> <td><input type="text" name="FatherOccupation"></td> <td>Monthly Salary</td> <td><input type="text" name="FatherSalary"></td> </tr> <tr> <td>Race:</td> <td><input type="text" name="FatherRace"></td> <td>Nationality:</td> <td><select name="FatherNationality" id="FatherNationality"> <option value="FatherNationality">Nationality</option> <option value="FatherNotNationality">Not Nationality</option> </select> </td> </tr> <tr> <td>Status :</td> <td><select name="FatherStatus"> <option value="FatherSingle">Single</option> <option value="FatherMarried">Married</option> <option value="FatherDivorce">Divorce</option> </select> </td> <td> </td> <td> </td> </tr> </table> <p align="center"><br> </br> <br> </br> <input type="submit" name="submit"> </form> <?php if(!isset($_POST['submit'])) { } else { $Name=(trim($_POST['Name'])=='')? die ('ERROR: Enter Name') : mysql_escape_string($_POST['Name']); $Gender=(trim($_POST['Gender'])=='')? die ('ERROR: Enter Gender') : mysql_escape_string($_POST['Gender']); $ID=(trim($_POST['ID'])=='')? die ('ERROR: Enter ID') : mysql_escape_string($_POST['ID']); $Age=(trim($_POST['Age'])=='')? die ('ERROR: Enter Age') : mysql_escape_string($_POST['Age']); $Address=(trim($_POST['Address'])=='')? die ('ERROR: Enter Address') : mysql_escape_string($_POST['Address']); $State=(trim($_POST['State'])=='')? die ('ERROR: Enter State') : mysql_escape_string($_POST['State']); $Occupation=(trim($_POST['Occupation'])=='')? die ('ERROR: Enter Occupation') : mysql_escape_string($_POST['Occupation']); $Salary=(trim($_POST['Salary'])=='')? die ('ERROR: Enter Salary') : mysql_escape_string($_POST['Salary']); $Race=(trim($_POST['Race'])=='')? die ('ERROR: Enter Race') : mysql_escape_string($_POST['Race']); $Nationality=(trim($_POST['Nationality'])=='')? die ('ERROR: Enter Nationality') : mysql_escape_string($_POST['Nationality']); $Status=(trim($_POST['Status'])=='')? die ('ERROR: Enter Status') : mysql_escape_string($_POST['Status']); $FatherName=(trim($_POST['FatherName'])=='')? die ('ERROR: Enter FatherName') : mysql_escape_string($_POST['FatherName']); $FatherNumber=(trim($_POST['FatherNumber'])=='')? die ('ERROR: Enter FatherName') : mysql_escape_string($_POST['FatherName']); $FatherID=(trim($_POST['FatherID'])=='')? die ('ERROR: Enter FatherID') : mysql_escape_string($_POST['FatherID']); $FatherAge=(trim($_POST['FatherAge'])=='')? die ('ERROR: Enter Age') : mysql_escape_string($_POST['FatherAge']); $FatherAddress=(trim($_POST['FatherAddress'])=='')? die ('ERROR: Enter FatherAddress') : mysql_escape_string($_POST['FatherAddress']); $FatherState=(trim($_POST['FatherState'])=='')? die ('ERROR: Enter FatherState') : mysql_escape_string($_POST['FatherState']); $FatherOccupation=(trim($_POST['FatherOccupation'])=='')? die ('ERROR: Enter FatherOccupation') : mysql_escape_string($_POST['FatherOccupation']); $FatherSalary=(trim($_POST['FatherSalary'])=='')? die ('ERROR: Enter FatherSalary') : mysql_escape_string($_POST['FatherSalary']); $FatherRace=(trim($_POST['FatherRace'])=='')? die ('ERROR: Enter FatherRace') : mysql_escape_string($_POST['FatherRace']); $FatherNationality=(trim($_POST['FatherNationality'])=='')? die ('ERROR: Enter FatherNationality') : mysql_escape_string($_POST['FatherNationality']); $FatherStatus=(trim($_POST['FatherStatus'])=='')? die ('ERROR: Enter FatherStatus') : mysql_escape_string($_POST['FatherStatus']); $connection=mysql_connect('localhost', 'root', '') or die ('Unable to connect'); mysql_select_db('projek') or die ('Unable to select database!'); $query= "INSERT INTO borang20 (Name, Gender, ID, Age, Address, State, Occupation, Salary, Race, Nationality, Status, Hubungan, FatherName, FatherNumber, FatherID, FatherAge, FatherAddress, FatherState, FatherOccupation, FatherSalary, FatherSalary, FatherRace, FatherNationality, FatherStatus) VALUES ('$Name', '$Gender', '$ID', '$Age', '$Address', '$State', '$Occupation', '$Salary', '$Race', '$Nationality', '$Status', '$FatherName', '$FatherNumber', '$FatherID', '$FatherAge', '$FatherAddress', '$FatherState', '$FatherOccupation', '$FatherSalary', '$FatherSalary, '$FatherRace', '$FatherNationality' '$FatherStatus')"; $result=mysql_query($query) or die ("ERROR in query:$query.".mysql_error()); echo 'New record has been successfully inserted'; mysql_close($connection); } ?> </body> </html> Im not kinda familiar with session and this moment i just realizes why my lecturer always ask me to attend programming classes while always with my PES2012 :'( Quote Link to comment https://forums.phpfreaks.com/topic/261568-newbie-question/#findComment-1340361 Share on other sites More sharing options...
louneas Posted April 26, 2012 Author Share Posted April 26, 2012 Those are my coding. In form_A.php i put form action equal to form_B.php so that after user fill up all fields user will click NEXT and it will bring user to form_B.php. In form_B.php , user also have to fill up fields and i put the form action that will post all the data from form_A.php and form_B.php to database by SUBMIT button in form_B.php But when the user click NEXT button in form_A.php, the data is not store. Any ways that when user fill up in form_A.php and click NEXT, it will bring user to form_B and at the same time it will bring along data TO SEND IT INTO DATABASE? how to use session along with my coding? Quote Link to comment https://forums.phpfreaks.com/topic/261568-newbie-question/#findComment-1340594 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.