Passing parameters using header location format

Posted on 2003-03-11
Medium Priority
Last Modified: 2011-10-03
I tried passing in a parameter using the header format but don't know how, can you fix this code please:

header('Location: Customer_Mare_Progress_Status.php')

?CustomerNo.=<?print $CustomerNo?>

Question by:willwatters
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
  • 2
LVL 15

Expert Comment

ID: 8113259
header("Location: Customer_Mare_Progress_Status.php?CustomerNo=$CustomerNo");

just a problem of single vs double quotes...
LVL 11

Accepted Solution

jausions earned 60 total points
ID: 8116585

Be aware that some web browsers expect a full URL and not just the last page. So you may need to do:

header('Location: http://myserver/Customer_Mare_Progress_Status.php?CustomerNo=' . $CustomerNo);

Of course replace "myserver" by the actual value. You could also do:


// Get server name and default port

// Get more detailed info
if (strpos($sHost, ':') !== false) {
  list($sHost, $iPort) = explode(':', $sHost);

// Build URL depending on protocol
if (isset($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) == 'ON') {
  // HTTP-S
  $sURL = 'https://' . $sHost . (($iPort == 443) ? '' : ':' . $iPort);
} else {
  // HTTPS
  $sURL = 'http://' . $sHost . (($iPort == 80) ? '' : ':' . $iPort);

// Should check for headers_sent() too
header('Location: ' . $sURL . dirname($_SERVER['PHP_SELF']) . '/Customer_Mare_Progress_Status.php?CustomerNo=' . $CustomerNo);

LVL 15

Expert Comment

ID: 8255294
well, did I "fix the code" or not ?
was my answer "thorough" enough or not ?

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
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

777 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