I've got a login page that I created in Dreamweaver to start a session variable, after login I've only got one choice on what page to direct them to, what I'd like help with is to know the code in order to create a PHP page that will see the username that they logged in with and then open up the link that I specified in mysql database in the "direct" row.
PHP dynamic redirect page
Collapse
X
-
It would be a little more helpful if you posted your code.Originally posted by kinobairnI've got a login page that I created in Dreamweaver to start a session variable, after login I've only got one choice on what page to direct them to, what I'd like help with is to know the code in order to create a PHP page that will see the username that they logged in with and then open up the link that I specified in mysql database in the "direct" row. -
<?php require_once('C onnections/useraccounts.ph p'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSI ON)) {
session_start() ;
}
$loginFormActio n = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername= $_POST['username'];
$password=$_POS T['textfield'];
$MM_fldUserAuth orization = "";
$MM_redirectLog inSuccess = "/clients/";
$MM_redirectLog inFailed = "/loginfailed.php ";
$MM_redirecttoR eferrer = true;
mysql_select_db ($database_user accounts, $useraccounts);
$LoginRS__query =sprintf("SELEC T username, password FROM Useraccounts WHERE username='%s' AND password='%s'",
get_magic_quote s_gpc() ? $loginUsername : addslashes($log inUsername), get_magic_quote s_gpc() ? $password : addslashes($pas sword));
$LoginRS = mysql_query($Lo ginRS__query, $useraccounts) or die(mysql_error ());
$loginFoundUser = mysql_num_rows( $LoginRS);
if ($loginFoundUse r) {
$loginStrGroup = "";
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSIO N['PrevUrl']) && true) {
$MM_redirectLog inSuccess = $_SESSION['PrevUrl'];
}
header("Locatio n: " . $MM_redirectLog inSuccess );
}
else {
header("Locatio n: ". $MM_redirectLog inFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>FreeHi ll Productions</title>
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
color: #FFFFFF;
font-weight: bold;
}
body {
background-color: #000000;
}
-->
</style></head>
<body>
<div align="center">
<p><a href="Demoreel/stream.html"></a></p>
<p> </p>
<p> </p>
<p> </p>
<form ACTION="<?php echo $loginFormActio n; ?>" id="clientlogin " name="clientlog in" method="POST">
<table width="275" height="108" border="0">
<tr>
<td> </td>
<td><label>
<div align="center"> Username
<input name="username" type="text" id="username" />
</div>
</label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><label>
<div align="center"> Password
<input type="password" name="textfield " />
</div>
</label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><label>
<div align="center">
<input type="submit" name="Submit" value="Submit" />
</div>
</label></td>
<td> </td>
</tr>
</table>
<label></label>
<p>
<label></label>
<label></label>
</p>
</form>
<p> </p>
<p> </p>
</div>
</body>
</html>
this is my login page, I'd like to have it direct the successful login to another page, possibly successfullogin .php, this page would direct the user to their individual folder based on the link I've got in the mysql database. I know so little about this, thank you for all the help. Please let me know if you need more informationComment
-
Perhaps you could try this...Originally posted by kinobairn<?php require_once('C onnections/useraccounts.ph p'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSI ON)) {
session_start() ;
}
$loginFormActio n = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername= $_POST['username'];
$password=$_POS T['textfield'];
$MM_fldUserAuth orization = "";
$MM_redirectLog inSuccess = "/clients/";
$MM_redirectLog inFailed = "/loginfailed.php ";
$MM_redirecttoR eferrer = true;
mysql_select_db ($database_user accounts, $useraccounts);
$LoginRS__query =sprintf("SELEC T username, password FROM Useraccounts WHERE username='%s' AND password='%s'",
get_magic_quote s_gpc() ? $loginUsername : addslashes($log inUsername), get_magic_quote s_gpc() ? $password : addslashes($pas sword));
$LoginRS = mysql_query($Lo ginRS__query, $useraccounts) or die(mysql_error ());
$loginFoundUser = mysql_num_rows( $LoginRS);
if ($loginFoundUse r) {
$loginStrGroup = "";
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSIO N['PrevUrl']) && true) {
$MM_redirectLog inSuccess = $_SESSION['PrevUrl'];
}
header("Locatio n: " . $MM_redirectLog inSuccess );
}
else {
header("Locatio n: ". $MM_redirectLog inFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>FreeHi ll Productions</title>
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
color: #FFFFFF;
font-weight: bold;
}
body {
background-color: #000000;
}
-->
</style></head>
<body>
<div align="center">
<p><a href="Demoreel/stream.html"></a></p>
<p> </p>
<p> </p>
<p> </p>
<form ACTION="<?php echo $loginFormActio n; ?>" id="clientlogin " name="clientlog in" method="POST">
<table width="275" height="108" border="0">
<tr>
<td> </td>
<td><label>
<div align="center"> Username
<input name="username" type="text" id="username" />
</div>
</label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><label>
<div align="center"> Password
<input type="password" name="textfield " />
</div>
</label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><label>
<div align="center">
<input type="submit" name="Submit" value="Submit" />
</div>
</label></td>
<td> </td>
</tr>
</table>
<label></label>
<p>
<label></label>
<label></label>
</p>
</form>
<p> </p>
<p> </p>
</div>
</body>
</html>
this is my login page, I'd like to have it direct the successful login to another page, possibly successfullogin .php, this page would direct the user to their individual folder based on the link I've got in the mysql database. I know so little about this, thank you for all the help. Please let me know if you need more information
Successfullogin .php...
Make the client login a session variable..
[PHP]
<?php
start_session() ;
$client=$_SESSI ON['client'];
$echotable=mysq l_fetch_array(m yql_query("SELE CT * FROM `tablename` WHERE `client`='$clie nt'"));
echo $echotable[0];
?>
[/PHP]
Also, in your regular login page... Try using arrays instead of the $MM__stuff..
[PHP]
Was...
$loginUsername= $_POST['username'];
$password=$_POS T['textfield'];
$MM_fldUserAuth orization = "";
$MM_redirectLog inSuccess = "/clients/";
$MM_redirectLog inFailed = "/loginfailed.php ";
$MM_redirecttoR eferrer = true;
Now...
$loginUsername= $_POST['username'];
$password=$_POS T['textfield'];
$MM=array("", "clients", "loginfailed.ph p", "true");
[/PHP]
And you simply call $MM by number entered.. like $MM_fldUserAuth orization would instead be $MM[0].Comment
Comment