Passing Variables of User Name & Password in Sessions
Posted: Wed Sep 01, 2004 7:47 am
Hello,
I'm having problem passing the UserName and Password fileds using the Sessions.
My First Page.( login.html)
My Second Page {login1.php}
My Third Page [review.php]
Please help me sort out the problem with passing the variables using sessions
I'm having problem passing the UserName and Password fileds using the Sessions.
My First Page.( login.html)
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="login1.php">
<p align="center"><strong><font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif"><u>Login
Information</u></font></strong></p>
<p align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong>
Name:
<input type="text" name="name">
</strong></font></p>
<p align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong>Password:
<input type="password" name="pass">
</strong></font></p>
<p align="center"><strong><font size="2">
<input type="submit" name="Submit" value="Submit">
</font></strong></p>
<p><br>
</p>
</form>
</body>
</html>Code: Select all
<?php session_start(); ?>
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
// Connection to Host and Database
require_once('Connections/mysql_conn.php');
$username = $_POST["name"];
$password = $_POST["pass"];
$result = MYSQL_QUERY("SELECT * from constant WHERE Uname='$username'and Password='$password'")
or die ("Name and password not found or not matched");
$worked = mysql_fetch_array($result);
if($worked)
{
$_SESSION['user'] = $username;
$_SESSION['pwd'] = $password;
$cval1 = $worked["cvalue1"];
$cval2 = $worked["cvalue2"];
$dval1 = $worked["dvalue1"];
$dval2 = $worked["dvalue2"];
echo "<br><br><form name="frm1" method="POST" action="review.php" >";
echo "<input type="hidden" value ='$username' name="un"> ";
echo "<input type="hidden" value ='$password' name="pw"> ";
echo " <br><br>CValue1 = <input type ="text" value= "$cval1" name="cv1"> ";
echo " <br><br>CValue2 = <input type ="text" value= "$cval2" disabled name="cv2"> ";
echo " <br><br>DValue1 = <input type ="text" value= "$dval1" name="dv1"> ";
echo " <br><br>DValue2 = <input type ="text" value= "$dval2" disabled name="dv2"> ";
echo "<br><br><input type="Submit" value="Submit">";
echo "</form>";
echo " USERNAME IS : $username<br><br> PASSWORD IS : $password";
}
else
{
echo "The Username and Password donot match";
}
?>
</body>
</html>Code: Select all
<?php session_start(); ?>
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
// Connection to Host and Database
require_once('Connections/mysql_conn.php');
//$username = $_POST["un"];
//$password = $_POST["pw"];
$_SESSION['user'] = $username;
$_SESSION['pwd'] = $password;
$ncv1 = $_POST["cv1"];
//$ncv2 = $_POST["cv2"];
$ndv1 = $_POST["dv1"];
//$ndv2 = $_POST["dv2"];
$result = MYSQL_QUERY("UPDATE constant SET cvalue1='$ncv1', dvalue1='$ndv1' where Uname='$username' and Password='$password' ")
or die ("Name and password not found or not matched");
if($result)
{
echo " <a href= "login1.php">Click here to review the Changes</a>";
echo " USERNAME IS : $username<br><br> PASSWORD IS : $password";
}
else
{
echo "The Username and Password donot match";
}
?>
</body>
</html>