Page 1 of 1
Simple redirecting problem
Posted: Fri Oct 24, 2008 8:49 am
by Sinbad_Sakic
Hi to everyone
I have the following problem:
I need from visitors of my website, to choose an item from item list, and depending on what they have selected, to be redirected to different pages, when submit is clicked.
The link will vary - so I created this script:
<?php
$first = $_REQUEST['first'] ;
$second = $_REQUEST['second'] ;
$address = '$first + $second' ;
header( "Location: http://www.somedomain.com/$address" );
?>
When I leave just one variable (for example, just
$first) the link is working, and everything is fine. But when I add another variable, $second, the link won't work.
Any ideas where the error might be?
Thanks in any case
SS

Re: Simple redirecting problem
Posted: Fri Oct 24, 2008 12:17 pm
by requinix
What are these first, second things supposed to be?
Re: Simple redirecting problem
Posted: Sat Oct 25, 2008 3:02 am
by Sinbad_Sakic
$first and $second are list menu's
Re: Simple redirecting problem
Posted: Sat Oct 25, 2008 3:54 am
by requinix
Sinbad_Sakic wrote:$first and $second are list menu's
And what does that mean?
Okay, forget that. How about an example of first and second and the page the user should get redirected too?
Re: Simple redirecting problem
Posted: Sat Oct 25, 2008 4:29 am
by Sinbad_Sakic
Sorry, maybe I should have put some examples of the first page too.
This is the code:
<html>
<head>
<title>Testing</title>
</head>
<body>
<form method="post" action="link.php">
Choose first option:
<select name="first" id="first">
<option value="valueone">Value One</option>
<option value="valuetwo">Value Two</option>
<option value="valuethree">Value Three</option>
</select>
<br />
<br />
Choose second option:
<select name="second" id="second">
<option value="valuefour" selected="selected">Value Four</option>
<option value="valuefive">Value Five</option>
<option value="valuesix">Value Six</option>
</select>
<br />
<input type="submit" />
</form>
</body>
</html>
The file link.php has the source as in my first post.
The page user will be redirected to will differ - all I need is to change the link according to what user has selected.
Thanks a lot
Re: Simple redirecting problem
Posted: Sat Oct 25, 2008 4:40 am
by Hannes2k
Hi,
your problem is you use just simple quotation marks ('). Variables wich are in '...' won't be replaced by the value.
Solution: $address = $first.' + '.$second;
Re: Simple redirecting problem
Posted: Sat Oct 25, 2008 5:16 am
by Sinbad_Sakic
Hannes2k wrote:Hi,
your problem is you use just simple quotation marks ('). Variables wich are in '...' won't be replaced by the value.
Solution: $address = $first.' + '.$second;
That solved the problem!
I tried everything but the right solution.
Thank you very much!
I gotta one more question. Is there any way to attach two values to a single option of list menu? And to name them different, so they could be used independent from each other.