Tried various solution from stack overflow and internet but none seems to be working. My php registration page is a modal window form. what I am looking for is to take the user back to the page from where he redirected to login form.
Register link:
<a data-toggle="modal" href="#myModal" class="btn btn-primary btn-lg">SIGN UP</a>
Register processing:
<?php
ob_start();
session_start();
require_once("config.php");
require_once("all_functions.php");
$cust_email = stripslashes($_POST['cust_email']);
$cust_password = stripslashes($_POST['cust_password']););
$res = mysql_query("SELECT * FROM register WHERE cust_email = '$cust_email'");
if (mysql_num_rows($res)>0)
{
echo 'That email is already registered';
exit;
}
mysql_query("INSERT INTO register (`cust_email`, `cust_password`)
VALUES
('$cust_email', '$cust_password')");
$_SESSION['valid_user'] = $cust_email;
header("Location: http://tre.com/");
exit;
?>
function to check user is logged in or not
<?php
function check_valid_user()
// see if somebody is logged in and notify them if not
{
global $_SESSION;
if (isset($_SESSION['valid_user']))
{
return $_SESSION['valid_user'];
}
else
{
return false;
}
}
?>