franches
10-04-2004, 07:34 AM
i know you will be able to help me with my probs.
could you please examine my code. this is the code that validates after the user enter username and password at the login page.
<?php
session_start();
$dbHost = "localhost"; // Database Connection Details - host
$dbUser = "root"; // Database Connection Details - username
$dbname = "TEST"; // Database Connection Details - database name
$username = $_POST['username'];
// Stores our inputted data in these variable names
$password = $_POST['password'];
// Stores our inputted data in these variable names
$db = mysql_connect($dbHost,$dbUser); // Connection Code
mysql_select_db($dbname); // Connects to database
$query = "(SELECT PIN, Password,Name FROM StaffTable WHERE PIN = '$username' AND Password = '$password')";
$result = mysql_query($query);
if(mysql_num_rows($result)) {
$_SESSION['loggedin'] = 1;
header('Location: <a href="http://copernicus/rhodora/statuslog/trial/admin.php" target="_blank">http://copernicus/rhodora/statuslog/trial/admin.php</a>');
exit(); }
else {
header('Location: <a href="http://copernicus/rhodora/statuslog/trial/...?error=1" target="_blank">http://copernicus/rhodora/statuslog/trial/...?error=1</a>');
exit(); }
?>
and this is my page after successful login. and my problem is I am not able to display the username which is the ID number or PIN of the user and his/her name. i think i used the wrong code in calling the PIN and Name.
thank you in advance. I'll be looking forward for your response.
<?php
session_start();
if(!isset($_SESSION['loggedin'])) {
header('Location: <a href="http://copernicus/rhodora/statuslog/trial/...?error=1" target="_blank">http://copernicus/rhodora/statuslog/trial/...?error=1</a>');
exit();
}
?>
<head>
<script>
blah blah
</script>
</head>
<body>
<?php
mysql_connect("localhost", "root")
or die( "Unable to connect\n". mysql_error() );
mysql_select_db("TEST")
or die("Unable to select db ".mysql_error()."\n");
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
<fieldset>
<div>
<label for="pin">PIN :</label> <? echo $username ?><br>
<label for="name">Name : </label><? echo $name ?> <br>
</div>
blah blah blah
</fieldset>
</form>
</body>
</html>
could you please examine my code. this is the code that validates after the user enter username and password at the login page.
<?php
session_start();
$dbHost = "localhost"; // Database Connection Details - host
$dbUser = "root"; // Database Connection Details - username
$dbname = "TEST"; // Database Connection Details - database name
$username = $_POST['username'];
// Stores our inputted data in these variable names
$password = $_POST['password'];
// Stores our inputted data in these variable names
$db = mysql_connect($dbHost,$dbUser); // Connection Code
mysql_select_db($dbname); // Connects to database
$query = "(SELECT PIN, Password,Name FROM StaffTable WHERE PIN = '$username' AND Password = '$password')";
$result = mysql_query($query);
if(mysql_num_rows($result)) {
$_SESSION['loggedin'] = 1;
header('Location: <a href="http://copernicus/rhodora/statuslog/trial/admin.php" target="_blank">http://copernicus/rhodora/statuslog/trial/admin.php</a>');
exit(); }
else {
header('Location: <a href="http://copernicus/rhodora/statuslog/trial/...?error=1" target="_blank">http://copernicus/rhodora/statuslog/trial/...?error=1</a>');
exit(); }
?>
and this is my page after successful login. and my problem is I am not able to display the username which is the ID number or PIN of the user and his/her name. i think i used the wrong code in calling the PIN and Name.
thank you in advance. I'll be looking forward for your response.
<?php
session_start();
if(!isset($_SESSION['loggedin'])) {
header('Location: <a href="http://copernicus/rhodora/statuslog/trial/...?error=1" target="_blank">http://copernicus/rhodora/statuslog/trial/...?error=1</a>');
exit();
}
?>
<head>
<script>
blah blah
</script>
</head>
<body>
<?php
mysql_connect("localhost", "root")
or die( "Unable to connect\n". mysql_error() );
mysql_select_db("TEST")
or die("Unable to select db ".mysql_error()."\n");
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
<fieldset>
<div>
<label for="pin">PIN :</label> <? echo $username ?><br>
<label for="name">Name : </label><? echo $name ?> <br>
</div>
blah blah blah
</fieldset>
</form>
</body>
</html>