Jump to content

Recommended Posts

basically you send them to a page, in this instance we'll call it redirect.php

 

if($variable1 == value){
header("Location: page1.php");
}elseif($variable2 == value2){
header("Location: page2.php");
}else{
echo "Error!";
}

 

If you told me what information was being bought to the page and how (by form, cookies etc..) I could be of more help

if ($_GET['verif']){
header("Location: trueverif.html");
}
elseif ($_GET['sinput']){
header("Location: truesinput.html");
}
elseif ($_GET['linput']){
header("Location: truelinput.html");
}
elseif ($_GET['vdata']){
header("Location: trueviewdata.html");
}
elseif ($_GET['rdata']){
header("Location: reportdata.php");
}

 

Why doesn't this code work then?

i just use javascript....

 

<?php 

if (condition){
     echo '<script>window.location = "page1.php"</script>';
} else if (condition2) {
     echo '<script>window.location = "page2.php"</script>';
} else {
     echo '<script>window.location = "page3.php"</script>';
}

?>

 

yours would be

 

if ($_GET['verif']){
echo '<script>window.location = "trueverif.html"</script>';
}
elseif ($_GET['sinput']){
echo '<script>window.location = "truesinput.html"</script>';
}
elseif ($_GET['linput']){
echo '<script>window.location = "truelinput.html"</script>';
}
elseif ($_GET['vdata']){
echo '<script>window.location = "trueviewdata.html"</script>';
}
elseif ($_GET['rdata']){
echo '<script>window.location = "reportdata.html"</script>';
}

Change your javascript so it includes the querystring:

 

<?php 

if (condition){
     echo '<script>window.location = "page1.php?verif"</script>';
} else if (condition2) {
     echo '<script>window.location = "page2.php?sinput"</script>';
} else {
     echo '<script>window.location = "page3.php?linput"</script>';
}

?>

This is what accesses it:

 

<html><head><title>AlibreCam Verification 

System</title></head>


<center>
<input type="submit" value="Verification" name = 

"verif">          
<input type="submit" value="Sales Input" name = 

"sinput">        
<input type="submit" value="License Input" name = 

"linput">         
<input type="submit" value="View Data" name = 

"vdata">         
<input type="submit" value="Report Data" name = 

"rdata">
</center>


</html>

 

 

read up on header().

http://us3.php.net/manual/en/function.header.php

 

You can not output ANYTHING (HTML, PHP print statements, etc) to the browser before you redirect with header(). If you want to redirect with it, make sure that it comes before any output to the browser.

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.