Solved

Redirect page in php with variable

Posted on 2011-02-26
4
261 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 38

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 63 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 62 total points
ID: 34990262
sjklein42 is right "$value" is evaluated in double quotes ... '$value' is passed on literally.

Ss
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now