Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Redirect page in php with variable

Posted on 2011-02-26
4
Medium Priority
?
269 Views
Last Modified: 2012-05-11
Hello,

I want to redirect page in php with variable.

I have variable  eg: $value
Assume $value=123;
and i am using code

<?php
header( 'Location: index.php?value=$value' ) ;

?>

but it doesn't work it shows link as it as

index.php?value=$value
0
Comment
Question by:savsofts
4 Comments
 
LVL 39

Expert Comment

by:Aaron Tomosky
ID: 34990245
Only echo does that automatically.
Value='.$value
0
 
LVL 3

Expert Comment

by:dtocci
ID: 34990246
Try something like this:
$value = 123;
$whereto = "index.php?" . $value;
header("Location: " . $whereto);
0
 
LVL 16

Accepted Solution

by:
sjklein42 earned 252 total points
ID: 34990248
I think if you use double-quotes instead of single-quotes, the $value would be expanded.

header( "Location: index.php?value=$value") ;

Open in new window

0
 
LVL 9

Assisted Solution

by:sshah254
sshah254 earned 248 total points
ID: 34990262
sjklein42 is right "$value" is evaluated in double quotes ... '$value' is passed on literally.

Ss
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question