Jump to content

form submission re-direct problem


gskurski

Recommended Posts

I'm having a problem which I'm sure will take a simple fix, but I can't seem to figure it out. I have a form now that lets you pick from six different options and then submit it to a redirect php file. In the php file I have an if, else if statement that is suppose to redirect to different pages corresponding to the original value selected in the form. Here is my code.

 

 

<form action="subredirect.php" method="post" target="index">

<select name="redirect">

<option value="vodka">Vodkas</option>

<option value="bourbons">Bourbons</option>

<option value="rum">Rums</option>

<option value="gin">Gins</option>

<option value="brandy">Brandy</option>

<option value="tequila">Tequila</option>

<option value="whiskey">Whiskey</option>

</select>

<input type="submit" value="Go!">

</form>

 

And here is my php file

<?php

if ($_POST(['redirect'])== "vodka"){
   header("Location: http://www.website.com/vodkasubmit.php");
   exit ();
}

elseif ($_POST(['redirect'])== "bourbon"){
   header("Location: http://www.website.com/bourbonsubmit.php");
   exit ();
}
elseif ($_POST(['redirect'])== "rum"){
   header("_POST(['redirect']): http://www.website.com/rumsubmit.php");
   exit ();
}
elseif ($_POST(['redirect'])== "gins"){
   header("Location: http://www.website.com/ginsubmit.php");
   exit ();
}
elseif ($_POST(['redirect'])== "brandy"){
   header("Location: http://www.website.com/brandysubmit.php");
   exit ();
}
elseif ($_POST(['redirect'])== "tequila"){
   header("Location: http://www.website.com/tequilasubmit.php");
   exit ();
}
elseif ($_POST(['redirect'])== "whiskey"){  
   header("Location: http://www.website.com/whiskeysubmit.php");
   exit ();
}
?>

Any help is really appreciated!

 

Thanks

 

-Gerry

Link to comment
Share on other sites

Try this:

<?php

if (isset($_POST['redirect'])){
header("Location: http://www.website.com/".$_POST['redirect']."submit.php");
exit();
}

?>


<form method="post" action="">
<select name="redirect">
	<option value="vodka">Vodkas</option>
	<option value="bourbons">Bourbons</option>
	<option value="rum">Rums</option>
	<option value="gin">Gins</option>
	<option value="brandy">Brandy</option>
	<option value="tequila">Tequila</option>
	<option value="whiskey">Whiskey</option>
</select>
<input type="submit" value="Go!">
</form>

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.