Jump to content

[SOLVED] PHP Conditional Redirection


DeepakJ

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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>';
}

Link to comment
Share on other sites

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>';
}

?>

Link to comment
Share on other sites

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>

 

 

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.