storing multiple html form values into single database recor
Posted: Sat Feb 07, 2009 3:25 am
Hello All,
I want to know that is it possible to store multiple form values into a single record of a table.
form1 (in login.html):
<form name="accountinput" method="post" action="st-log1.php">
Account type:
<input type="radio" name="account" value="1">Student
<input type="radio" name="account" value="2">Faculty</td>
Enter Valid e-mail:
<input type="text" name="email">
<input type="submit" value="submit"></td>
</form>
form2(in st-log1.php):
<form name="user_info" action="variables.php" method="post">
Admission number: <input type="text" name="admission">
Username: <input type="text" name="user">
Password: <input type="password" name="password">
Re-enter password:<input type="password" name="password">
Gender: <input type="radio" name="gender" value="M">Male
<input type="radio" name="gender" value="F">Female
<input type="submit" value="submit">
</form>
php code in (variable.php):
<?php
$con = mysql_connect("localhost","root","");
if(!$con)
{
die('could not connect:'. mysql_error());
}
mysql_select_db("cis",$con);
$sql = "INSERT INTO user(type_id, email_id, admission_no, user_name, password, gender) VALUES ('$_POST[account]','$_POST[email]','$_POST[admission]','$_POST[user]','$_POST[password]','$_POST[gender]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con)
?>
here m first trying to read all the values from first form. Then moving to st-log1.php page and after reading all the values in form 2 in that page i want submit both the form values as a single record of user table in database...pls anyone guide me wheather it is possible or not..any help would be greatly appreciated.
I want to know that is it possible to store multiple form values into a single record of a table.
form1 (in login.html):
<form name="accountinput" method="post" action="st-log1.php">
Account type:
<input type="radio" name="account" value="1">Student
<input type="radio" name="account" value="2">Faculty</td>
Enter Valid e-mail:
<input type="text" name="email">
<input type="submit" value="submit"></td>
</form>
form2(in st-log1.php):
<form name="user_info" action="variables.php" method="post">
Admission number: <input type="text" name="admission">
Username: <input type="text" name="user">
Password: <input type="password" name="password">
Re-enter password:<input type="password" name="password">
Gender: <input type="radio" name="gender" value="M">Male
<input type="radio" name="gender" value="F">Female
<input type="submit" value="submit">
</form>
php code in (variable.php):
<?php
$con = mysql_connect("localhost","root","");
if(!$con)
{
die('could not connect:'. mysql_error());
}
mysql_select_db("cis",$con);
$sql = "INSERT INTO user(type_id, email_id, admission_no, user_name, password, gender) VALUES ('$_POST[account]','$_POST[email]','$_POST[admission]','$_POST[user]','$_POST[password]','$_POST[gender]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con)
?>
here m first trying to read all the values from first form. Then moving to st-log1.php page and after reading all the values in form 2 in that page i want submit both the form values as a single record of user table in database...pls anyone guide me wheather it is possible or not..any help would be greatly appreciated.