Solved

Redirect page in php with variable

Posted on 2011-02-26
4
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
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 count occurrences of each item in an array.

710 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