473,395 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

PHP dynamic redirect page

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.
Mar 6 '07 #1
3 3820
The1corrupted
134 100+
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.
It would be a little more helpful if you posted your code.
Mar 7 '07 #2
<?php require_once('Connections/useraccounts.php'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['textfield'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "/clients/";
$MM_redirectLoginFailed = "/loginfailed.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_useraccounts, $useraccounts);

$LoginRS__query=sprintf("SELECT username, password FROM Useraccounts WHERE username='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

$LoginRS = mysql_query($LoginRS__query, $useraccounts) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>FreeHill 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>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form ACTION="<?php echo $loginFormAction; ?>" id="clientlogin" name="clientlogin" method="POST">
<table width="275" height="108" border="0">
<tr>
<td>&nbsp;</td>
<td><label>
<div align="center">Username
<input name="username" type="text" id="username" />
</div>
</label></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<div align="center">Password
<input type="password" name="textfield" />
</div>
</label></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<div align="center">
<input type="submit" name="Submit" value="Submit" />
</div>
</label></td>
<td>&nbsp;</td>
</tr>
</table>
<label></label>
<p>
<label></label>
<label></label>
</p>
</form>
<p>&nbsp;</p>
<p>&nbsp;</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
Mar 7 '07 #3
The1corrupted
134 100+
<?php require_once('Connections/useraccounts.php'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['textfield'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "/clients/";
$MM_redirectLoginFailed = "/loginfailed.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_useraccounts, $useraccounts);

$LoginRS__query=sprintf("SELECT username, password FROM Useraccounts WHERE username='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

$LoginRS = mysql_query($LoginRS__query, $useraccounts) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>FreeHill 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>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form ACTION="<?php echo $loginFormAction; ?>" id="clientlogin" name="clientlogin" method="POST">
<table width="275" height="108" border="0">
<tr>
<td>&nbsp;</td>
<td><label>
<div align="center">Username
<input name="username" type="text" id="username" />
</div>
</label></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<div align="center">Password
<input type="password" name="textfield" />
</div>
</label></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<div align="center">
<input type="submit" name="Submit" value="Submit" />
</div>
</label></td>
<td>&nbsp;</td>
</tr>
</table>
<label></label>
<p>
<label></label>
<label></label>
</p>
</form>
<p>&nbsp;</p>
<p>&nbsp;</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
Perhaps you could try this...

Successfullogin.php...

Make the client login a session variable..

[PHP]
<?php
start_session();
$client=$_SESSION['client'];
$echotable=mysql_fetch_array(myql_query("SELECT * FROM `tablename` WHERE `client`='$client'"));

echo $echotable[0];
?>
[/PHP]

Also, in your regular login page... Try using arrays instead of the $MM__stuff..

[PHP]
Was...
$loginUsername=$_POST['username'];
$password=$_POST['textfield'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "/clients/";
$MM_redirectLoginFailed = "/loginfailed.php";
$MM_redirecttoReferrer = true;
Now...
$loginUsername=$_POST['username'];
$password=$_POST['textfield'];
$MM=array("", "clients", "loginfailed.php", "true");
[/PHP]
And you simply call $MM by number entered.. like $MM_fldUserAuthorization would instead be $MM[0].
Mar 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Erik Andersson | last post by:
Hi! I need to translate the path /category_name/sub_category_name/ to /category.php?sub_category_id=2
0
by: only_me | last post by:
Not a coding question as such but highly related to asp/dynamic pages issues : has anyone any suggestions on the following ASP sites are generally (always) of a dynamic nature, pages can be...
0
by: Martin | last post by:
Hi. I had a very frustrating afternoon and evening but I have got it all under control now so all of a sudden I am in a good mood. I want to share some insights on output caching with you lot. ...
10
by: moondaddy | last post by:
I'm writing an ecommerce app in asp.net/vb.net and need to make the pages searchable and crawlable by spiders, particularly Google's. As far as I know, if my pages's contents are mostly populated...
2
by: John Ninan | last post by:
I am creating Dynamic Usercontrol in Asp.net application. In this application I have a combobox(aspx Page). Which contains various items. Based on item selected I am dynamically populating...
2
by: Developer_Software | last post by:
Thanks in advance to anyone who can help :) I've got a placeholder control WITHIN A USER CONTROL that has its contents dynamically added and removed at runtime by a regular .aspx page. At...
4
by: Mark Rae | last post by:
Hi, I have a site which uses dynamic MasterPages. The selection of the MasterPage to use is determined by an encrypted QueryString. Session_Start looks for the presence of the QueryString,...
0
by: Francois | last post by:
I have to modify existing code : Basically, it implemnts tabbed forms. On the pageLoad, the code creates the two selection controls, plus kind of page depending of selected control. On...
1
by: Fabio | last post by:
Hi I am very new to C#.NET 2.0 I was wondering if someone can help please. I have a screen with a datalist control. The data in the list can contain x amount of rows (usually a low number)....
5
by: Nick | last post by:
Hi there, I am adding a meta redirect tag to the page dynamically on 2 separate pages in asp.net. One of the pages it works fine, and 5 seconds after the page appears, the redirect occurs. On...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.