LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-17-2009, 12:56 PM   #1
imkornhulio
Member
 
Registered: Aug 2008
Posts: 58

Rep: Reputation: 15
php header location problem


I am trying to pass some header form value to asp page from php. Below is my code. Can someone help me and tell me what am i doing wrong

<?php
header( "Location:
http://domain.com/register.asp?code1=".urlencode($_GET['code1'])"&code2=".urlencode($_GET['code2']));
?>

Thanks in advance

Last edited by imkornhulio; 03-17-2009 at 12:58 PM.
 
Old 03-17-2009, 01:16 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

Superficially, it looks OK.

Strong suggestion:
1. Look at this link (it has some extra syntax that might be applicable here):
http://www.php-mysql-tutorial.com/wi...variables.aspx

2. For debugging purposes, "echo" each of your _$GET variables
Code:
<?php
  // NOTE: for debugging *only*!  Do *NOT* use in production code!
  print(’<pre>’);
  print_r($_GET);
  print(’</pre>’);
?>
'Hope that helps ... and let us know what you find!
 
Old 03-17-2009, 01:44 PM   #3
imkornhulio
Member
 
Registered: Aug 2008
Posts: 58

Original Poster
Rep: Reputation: 15
<?php
header( "Location:
http://domain.com/register.asp?code1="99999"&code2="888888");
?>


When i hardcode the number it works. i also did echo to all the variable and they show right numbers. Weird problem.
i even the command below to goto that page directly it goes to that page but environment variables are not transferred.

<?php
header( "Location:
http://domain.com/register.asp");
?>

Any help will greatly be appreciated

Last edited by imkornhulio; 03-17-2009 at 01:47 PM.
 
Old 03-17-2009, 01:50 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
The question remains: does the HTTP session executing your PHP script happen to *have* a "GET" variable named "code1"? And if so, can you successfully access it via the PHP "$_GET[]" variable array?

The "$_GET[]", of course, refers to what you've *got* (not what you're *giving*) ;-)

'Hope that helps .. PSM
 
Old 03-17-2009, 02:33 PM   #5
imkornhulio
Member
 
Registered: Aug 2008
Posts: 58

Original Poster
Rep: Reputation: 15
I do have that variable passing from a form
 
Old 03-17-2009, 02:39 PM   #6
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
So why doesn't "$_GET[]" seem to be seeing it? *That's* the question I suggested you try debugging.

Please take a look at the tutorial, please take a look at the "curly brace" syntax, and please try "echo" statements to see if you're correctly getting *any* of your "GET" variables.

And, of course, double-check your URL to make sure the "GET" is there in the first place ;-)

Please post back what you find .. PSM
 
Old 03-17-2009, 03:32 PM   #7
imkornhulio
Member
 
Registered: Aug 2008
Posts: 58

Original Poster
Rep: Reputation: 15
it was syntax. Code change {} below did it.

Thanks alot


header( "Location:
http://domain.com/register.asp?code1={$_GET['code1']}&code2={$_GET['code2']}");
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
using header('location:... syok Programming 1 08-06-2008 10:56 PM
How to supply extra commands along with PHP header("Location: http://www.abc.com")? alphaque Programming 3 05-26-2006 04:28 AM
PHP header("Location: xxx.php") not working? baddah Programming 7 05-10-2006 09:00 AM
PHP header("Location") Gerardoj Programming 1 05-11-2004 04:29 PM
php header redirect problem after upload rvn Linux - Newbie 2 02-08-2004 07:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration