Hi everybody,
I need some help forming a login script that will take different logins to different pages.
I have enabled my cms so I can create new users and give them a unique password.
At the moment the login works but takes all users to the same page.
What I want is for the login to take all users to the same php file but for that file to display different information depending on who logged in.
The file is a client feedback form which will show the client information at the top so that when submitted we know who it came from.
So all I need is some code so when a user hits the "login" button,it takes them to the form and displays their info at the top, which happens to be the username (client name) and password (project number)
Login script...
<?php
session_start();
$errorMessage = '';
if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {
include 'library/config.php';
include 'library/opendb.php';
$userId = $_POST['txtUserId'];
$password = $_POST['txtPassword'];
$sql = "SELECT client_name
FROM clients
WHERE client_name = '$userId' AND project_number = '$password'";
$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
if (mysql_num_rows($result) == 1) {
$_SESSION['db_is_logged_in'] = true;
header('Location: survey.php');
exit;
} else {
$errorMessage = 'Sorry, wrong user id / password';
}
include 'library/closedb.php';
}
require('includes/header10.php');
?>
<html>
<head>
<title>Basic Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<div id="main4">
<body>
<table width="510" cellpadding="3" cellspacing="0" align="center">
<tr><td align="center" bgcolor="#374559" width="510" height="22">
<h1>CLIENT LOGIN PAGE</h1>
</td></tr>
</table>
<br><br>
<?php
if ($errorMessage != '') {
?>
<p align="center"><strong><font color="#990000"><?php echo $errorMessage; ?></font></strong></p>
<?php
}
?>
<form action="" method="post" name="frmLogin" id="frmLogin">
<table width="300" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="100">Username</td>
<td><input name="txtUserId" type="text" id="txtUserId"></td>
</tr>
<tr>
<td width="100">Password</td>
<td><input name="txtPassword" type="password" id="txtPassword"></td>
</tr>
<tr>
<td width="100"> </td>
<td><input name="btnLogin" type="submit" id="btnLogin" value="Login"></td>
</tr>
</table>
</form>
<br><br><br><br><br><br><br><br>
</body>
</html>
<?php
require('includes/footer.php');
?>
and the survey.php page which users reach when successfully logged in...
<?php
session_start();
if (!isset($_SESSION['db_is_logged_in']) || $_SESSION['db_is_logged_in'] !== true) {
header('Location: clientsurvey.php');
exit;
}
require('includes/header10.php');
?>
<div id="container3">
<html>
<head>
<title>Resolve Group Admin Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<p><h2>Resolve Group Client Survey</h2>
</head>
<body>
<form method=post action="http://elena.aut.ac.nz/cgi-bin/infomail.cgi">
<p>
<?php
$username="root";
$password="";
$database="resolve";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM clients";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$project_number=mysql_result($result,$i,"project_number");
$project_name=mysql_result($result,$i,"project_name");
$client_name=mysql_result($result,$i,"client_name");
$contact_person=mysql_result($result,$i,"contact_person");
echo "<b>Project Number: </b>$project_number<br>";
echo "<b>Project Name: </b>$project_name<br>";
echo "<b>Client Name: </b>$client_name<br>";
echo "<b>Contact Person: </b>$contact_person";
$i++;
}
?><hr align="left" width="650">
<p>
<h1>How did you hear about Resolve Group?</h1>
<p>
.........
Please help if you know anything about login scripts!...