Simple redirecting problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sinbad_Sakic
Forum Newbie
Posts: 4
Joined: Fri Oct 24, 2008 8:40 am

Simple redirecting problem

Post 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 :)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Simple redirecting problem

Post by requinix »

What are these first, second things supposed to be?
Sinbad_Sakic
Forum Newbie
Posts: 4
Joined: Fri Oct 24, 2008 8:40 am

Re: Simple redirecting problem

Post by Sinbad_Sakic »

$first and $second are list menu's
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Simple redirecting problem

Post 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?
Sinbad_Sakic
Forum Newbie
Posts: 4
Joined: Fri Oct 24, 2008 8:40 am

Re: Simple redirecting problem

Post 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
Hannes2k
Forum Contributor
Posts: 102
Joined: Fri Oct 24, 2008 12:22 pm

Re: Simple redirecting problem

Post 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;
Sinbad_Sakic
Forum Newbie
Posts: 4
Joined: Fri Oct 24, 2008 8:40 am

Re: Simple redirecting problem

Post 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! :drunk:
I tried everything but the right solution. :banghead:

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.
Post Reply