problem with redirect
Posted: Tue Jul 03, 2007 8:03 am
JayBird | Please use
If they have registered etc the there is code further down the page do do.
My problem is that although there is a redirect if the user is not registered and it does redirect, it still appears to add the details to a booking table etc. which is what the code further down does.
Have i made a fundemental series or errors in my thinking here. how can I stop the code further down the page happening if the user needs to be redirected?
Any help would be appreciated
JayBird | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have a page that is checking info to see if this is the appropriate page for the user to be on. if it is it looks up the registered persons details and books them onto a course. if they are not it should redirect to a page for them to register first.
There are two checks above the html code which deal with the redirects. The first check is to see if the user has logged on which has a header redirect in it. the second is to see if they are all registered. This too has a header redirect on which seems to be working.
I have split the code into 2 sections. the top deals with the checking etc and appears before the usual html stuff ( I want this page to look like the rest on the site I need the html stuff there.) the code is as followsCode: Select all
<?php
session_start();
if (!isset($_SESSION['valid_user'])){
header("Location: login.php");
}
else
{
$courseid= $_POST['courseid'];
$email = $_POST['requiredEmail'];
//get connection to database
$linkID = @mysql_connect("localhost", "root", "");
mysql_select_db("ivanhoe", $linkID);
//set error reporting to display and to it's highest level in case
//it's not and you're missing vital notices and/or warnings:
ini_set('display_errors', 1);
error_reporting(E_ALL);
$sql ="SELECT * FROM clients WHERE email LIKE '$email'";
$resultID = mysql_query($sql, $linkID)or die(mysql_error());
if(mysql_num_rows($resultID) < 1)
{
$goto ="notregistered.php?id=$courseid";
header( "Location: $goto" );
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">My problem is that although there is a redirect if the user is not registered and it does redirect, it still appears to add the details to a booking table etc. which is what the code further down does.
Have i made a fundemental series or errors in my thinking here. how can I stop the code further down the page happening if the user needs to be redirected?
Any help would be appreciated
JayBird | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]