Jump to content

header not redirecting


Timinator2000

Recommended Posts

Ok, I am having a hard time with the header function.. if you look at the script below, both the 2 first header functions work no problem upon given cirumstances.. but as soon as I add the last header function, the first header function does not work.. it always reverts to the last header..  what am i doing wrong?

 

Thanks everyone.

 

CODE:

 

<?

 

//------------------------------------------------------------------------------------------------------------------

// VARIABLE DECLARATION..

$username = $_GET['user'];

$password = $_GET['password'];

$Button = $_GET['Button'];

 

//------------------------------------------------------------------------------------------------------------------

 

// FUNCTION LOGIN INTO LOGIN DATABASE

 

function readdata() {

...deleted for posting purposes..}

//------------------------------------------------------------------------------------------------------------------

if ($Button == "Cancel"){

@header("Location: http://www.xxx.com/Mainview.php?selected=poker");

}

if ($Button == "Submit"){

!readdata();

$query="SELECT * FROM `login`";

$result=mysql_query($query) or die("Query failed: $query\nError: " . mysql_error());

$num_entries=mysql_numrows($result);

mysql_close();

$i=0;

while ($i < $num_entries) {

$sqluser=mysql_result($result,$i,'user');

$sqlpass=mysql_result($result,$i,'pass');

if ($username == $sqluser && $password == $sqlpass) {

@header("Location: http://www.xxx.com/test2.php");

}

$i++;

}

}

@header("Location: http://www.xxx.com/signin.php?flag=invalid");

 

 

?>

Link to comment
Share on other sites

You're welcome :)

And in the future, maybe consider using if, elseif, else if you want to do something if two conditions aren't met.

 

<?php
if (first condition) {
//do something if first condition is met;
} elseif (second condition) {
//do something if first condition isn't met, but the second is;
} else {
//do something if none of the conditions were met;
}
?>

 

But it is always a good idea to exit your script after a header redirect.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.