I'm working on the form that will redirect user after entering their zip code in text box for this examples when they Enter
11111 and 22222 they will redirected to google.com
33333 and 44444 they will redirected to yahoo.com
55555 and 66666 they will redirected to bing.com
Here's my redirect_form.php
<form method="post" id="#form" action="redirect_form.php" >
<input type='text' name="zip" id="zip" placeholder='Enter Your Zip Code'/>
<input type='submit' id='btn' name="submit" Value='Submit' /><br />
<?php
include "include/redirect.php";
?>
</form>
And Here's my redirect.php
<?php
if(isset($_POST['submit'])){
//Fetching variables of the form which travels in URL
$zip = $_POST['zip'];
if($zip =='11111' || $zip =='22222')
{
//To redirect form on a particular page
header("Location:http://www.google.com");
}
else if($zip =='33333' || $zip =='44444')
{
//To redirect form on a particular page
header("Location:http://www.yahoo.com");
}
else if($zip =='55555' || $zip =='66666')
{
//To redirect form on a particular page
header("Location:http://bing.com");
}
else{
?><span><?php echo "Please enter your Zip code.....!!!!!!!!!!!!";?></span> <?php
}
}
?>
But after I tested my form, for example I enter 11111 it gives me this error:
Warning: Cannot modify header information - headers already sent by (output started at /home2/mighty1/public_html/epic/redirect_form/redirect_form.php:12) in /home2/mighty1/public_html/epic/redirect_form/include/redirect.php on line 8
The line no.8 in redirect.php is header("Location:http://www.yahoo.com");
Can someone help me :)
Thank you
Aucun commentaire:
Enregistrer un commentaire