Forum Moderators: coopster
i have a page called 1.php which then has links to either pages called.
3.php
4.php
5.php
problem is on these pages it has a script thats checks if the user is logged in! if they are not they are directed to login.php BUT now when they click sumbit i want them to be taken to the page they orginally selected ie 3,4 or 5 .php
any help is much welcomed. thanks
[webmasterworld.com...]
Which part are you stuck on?
<form action="handle.php" method="POST">
<input type="text" name="username">
<input type="password" name="password">
-----------
handle.php
-------------
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
$_SESSION['username']=$username;
$_SESSION['password']=$password;
// Connect to MySQL
mysql_connect( 'localhost', aaa, 'admin' )
or die ( 'Unable to connect to server.' );
// Select database on MySQL server
mysql_select_db( aa)
or die ( 'Unable to select database.' );
// Formulate the query
$sql = "SELECT * FROM users WHERE
username = '$username' AND
password = '$password'";
// Execute the query and put results in $result
$result = mysql_query( $sql )
or die ( 'Unable to execute query.' );
// Get number of rows in $result.
$num = mysql_numrows( $result );
if ( $num!= 0 ) {
// A matching row was found - the user is authenticated.
$_SESSION['auth']='true';
header("Location: sell.php");
} else {
$_SESSION['auth']='false';
header("Location: login.php");
}
?>
-------------------------------
handle is where i will need to have the redirect to the last visited page.
where will i put the code and can someone tell me what the code should look like please.
thanks
My login check script is included at the top of every page, I can then use the $_SERVER['REQUEST_URI'] to grab the requested url. Then if they don't pass authentication, since the session is started, I can throw the page into a variable.
$_SESSION['requestedpage'] = $_SERVER['REQUEST_URI'];
then let them login, at the end of your login script
if (isset($_SESSION['requestedpage'])) {
header("Location: " . $_SESSION['requestedpage']);
} else {
header("Location: somepage.php");
}
something along those lines
problem is when the back button is used and the error is Notice: Undefined index: myselect_1 in C:\Inetpub\wwwroot\aa\sells3.php on line 21
i get one of these for most varibles..
the way to sort this is throught what i ask maybe
GET
i dont know can some one let me know please or how about if i disable the back button what is the best action please
You could sie the script and then give them a notice that if they use the back button during the process they will have to start over.