hi, i am trying to use a hidden form as a method of storing varibles for use throughout an online quiz site.
I am using mysql to hold data about the users ie user id username and user password etc.
The information is input into a visible form and then when the user clicks the submit button, a validatelogin.p hp script is run which takes the data from the input and checks it against the mysql database.
I want to know if there is a way of taking the data from one form, running it thorugh this php script below and then assigning the data from the php variables to the hidden form?
here is the php file:
<?php
session_start() ;
$host="localhos t"; // Host name
$username="root "; // Mysql username
$password="xxxx xxxxx"; // Mysql password
$db_name="test" ; // Database name
$tbl_name="Stud ent"; // Table name
// Connect to server and select databse.
mysql_connect(" $host", "$username" , "$password" )or die("cannot connect");
mysql_select_db ("$db_name") or die("cannot select DB");
// username and password sent from signup form
$myusername=$_P OST['studentusernam e'];
$mypassword=$_P OST['studentpasswor d'];
//HERE I WANT TO ASSIGN $myusername and $mypassword to the fields in the hidden form called 'hiddenuser' and 'hiddenpassword '
$_SESSION['user']=$myusername;
$sql="SELECT * FROM $tbl_name WHERE userName='$myus ername' and userPassword='$ mypassword'";
$result=mysql_q uery($sql);
// Mysql_num_row is counting table row
$count=mysql_nu m_rows($result) ;
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
session_registe r("studentusern ame");
session_registe r("studentpassw ord");
header("locatio n:welcome.xml") ;
}
else {
header("locatio n:failedlogin.x ml");
}
?>
I am using mysql to hold data about the users ie user id username and user password etc.
The information is input into a visible form and then when the user clicks the submit button, a validatelogin.p hp script is run which takes the data from the input and checks it against the mysql database.
I want to know if there is a way of taking the data from one form, running it thorugh this php script below and then assigning the data from the php variables to the hidden form?
here is the php file:
<?php
session_start() ;
$host="localhos t"; // Host name
$username="root "; // Mysql username
$password="xxxx xxxxx"; // Mysql password
$db_name="test" ; // Database name
$tbl_name="Stud ent"; // Table name
// Connect to server and select databse.
mysql_connect(" $host", "$username" , "$password" )or die("cannot connect");
mysql_select_db ("$db_name") or die("cannot select DB");
// username and password sent from signup form
$myusername=$_P OST['studentusernam e'];
$mypassword=$_P OST['studentpasswor d'];
//HERE I WANT TO ASSIGN $myusername and $mypassword to the fields in the hidden form called 'hiddenuser' and 'hiddenpassword '
$_SESSION['user']=$myusername;
$sql="SELECT * FROM $tbl_name WHERE userName='$myus ername' and userPassword='$ mypassword'";
$result=mysql_q uery($sql);
// Mysql_num_row is counting table row
$count=mysql_nu m_rows($result) ;
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
session_registe r("studentusern ame");
session_registe r("studentpassw ord");
header("locatio n:welcome.xml") ;
}
else {
header("locatio n:failedlogin.x ml");
}
?>
Comment