473,549 Members | 5,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with variables in header location

Hi

this is probably very easy to sort but I want to do the following:-

header( "Location:
subscribe_form. php?name='.$_GE T['name'].'&email='.$_GE T['email'].'");

but this pulls up the error:-

Parse error: parse error, unexpected T_ENCAPSED_AND_ WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in
/home/httpd/vhosts/promotingmusic. co.uk/httpdocs/test/subscribe.php on line
11

the above being line 11. How would I go about encoding the URL properly. The
reason I am doing this is that I am using a form that is being validated via
another script and if there is a problem I wish to fiorward them back to the
form with it pre filled in.

Also is this the correct method for doing this.

Cheers in advance.
Jul 17 '05 #1
6 18261
Filth wrote:
Hi

this is probably very easy to sort but I want to do the following:-

header( "Location:
subscribe_form. php?name='.$_GE T['name'].'&email='.$_GE T['email'].'");

but this pulls up the error:-

Parse error: parse error, unexpected T_ENCAPSED_AND_ WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in
/home/httpd/vhosts/promotingmusic. co.uk/httpdocs/test/subscribe.php on line
11

the above being line 11. How would I go about encoding the URL properly. The
reason I am doing this is that I am using a form that is being validated via
another script and if there is a problem I wish to fiorward them back to the
form with it pre filled in.

Also is this the correct method for doing this.

Cheers in advance.


You aren't closing your quotes
header("Locatio n: subscribe_form. php?name='" . _GET['name'] . "&email="
.....etc

~Cameron
Jul 17 '05 #2
> > header( "Location:
subscribe_form. php?name='.$_GE T['name'].'&email='.$_GE T['email'].'");
Parse error: parse error, unexpected T_ENCAPSED_AND_ WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in
/home/httpd/vhosts/promotingmusic. co.uk/httpdocs/test/subscribe.php on line 11


You aren't closing your quotes
header("Locatio n: subscribe_form. php?name='" . _GET['name'] . "&email="
....etc


Hi Cameron cheers for the quick response I notice in your example you missed
off the $ in the get variable was this meant or is it a typo (I presume it
was a typo) also I am presuming it is another type but you have closed a "
using a ' followed by a "

working on my presumptions I tried:-

header("Locatio n: subscribe_form. php?name=" ". $_GET['name'] . '&email=' .
$_GET['email'] ." );

and

header("Locatio n: subscribe_form. php?name=" ". $_GET['name'] ." '&email=' ".
$_GET['email'] ." );

which gave me the following error:-

Parse error: parse error, unexpected '\"' in
/home/httpd/vhosts/promotingmusic. co.uk/httpdocs/test/subscribe.php on line
11

Can you see what I am doing wrong?
Jul 17 '05 #3
Filth wrote:

Hi

this is probably very easy to sort but I want to do the following:-

header( "Location:
subscribe_form. php?name='.$_GE T['name'].'&email='.$_GE T['email'].'");

but this pulls up the error:-

Parse error: parse error, unexpected T_ENCAPSED_AND_ WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in
/home/httpd/vhosts/promotingmusic. co.uk/httpdocs/test/subscribe.php on line
11

the above being line 11. How would I go about encoding the URL properly. The
reason I am doing this is that I am using a form that is being validated via
another script and if there is a problem I wish to fiorward them back to the
form with it pre filled in.


A few problems:

Always url_encode your variables when they're in a header. Otherwise, if you
have a space or another invalid character you'll get an error.
You should use absolute URLs in the location header. Some browsers do not
support relative URLs.
Single and double quotes aren't interchangable (I assume you don't want single
quotes in the email and name variables).
Always close your quotes.

header( "Location:
http://yourdomain.com/script.php?name =".url_encode($ _GET['name'])."&email=".url encode($_GET['email']));

Regards,
Shawn
--
Shawn Wilson
sh***@glassgian t.com
http://www.glassgiant.com
Jul 17 '05 #4
> header( "Location:

http://yourdomain.com/script.php?name =".url_encode($ _GET['name'])."&email=".url encode($_GET['email']));

Thank you it worked perfectly except for the _ in the first urlencode.

Just so that I know for future reference why does the first get variable
have a . on either side but the second only has 1.

Regarding the urlencode not being there I was thinking wether I should be
doing that before infact I was looking at using rawurlencode() but wanted to
get it working first before I started with that

Cheers again

Peter
Jul 17 '05 #5
Filth wrote:
header( "Location:

http://yourdomain.com/script.php?name =".url_encode($ _GET['name'])."&email=".url encode($_GET['email']));

Thank you it worked perfectly except for the _ in the first urlencode.

Just so that I know for future reference why does the first get variable
have a . on either side but the second only has 1.

Regarding the urlencode not being there I was thinking wether I should be
doing that before infact I was looking at using rawurlencode() but wanted to
get it working first before I started with that


Whoops. My mistake with the underscore.

The "." means append, add or join. If you had more stuff to tack on the end it
would be:

blah...blah...b lah...email=".u rlencode($_GET['email'])."&foo=bar") ;

But since you didn't, you did not need the dot.

$string = "A"."B"."C" ; //$string is "ABC"
$string = "A"."B"; //$string is "AB"
$string = "A"."B".""; //$string is "AB". Extra dot is not needed

Regards,
Shawn
--
Shawn Wilson
sh***@glassgian t.com
http://www.glassgiant.com
Jul 17 '05 #6
> The "." means append, add or join. If you had more stuff to tack on the
end it
would be:

blah...blah...b lah...email=".u rlencode($_GET['email'])."&foo=bar") ;

But since you didn't, you did not need the dot.

$string = "A"."B"."C" ; //$string is "ABC"
$string = "A"."B"; //$string is "AB"
$string = "A"."B".""; //$string is "AB". Extra dot is not needed


Ahh brilliant explanation I now understand completely CHEERS :>

Peter
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
34282
by: bob | last post by:
I use the following code to redirect the browser on an error, header("location:error.php"); exit; Is it possible to pass POST variables on as if a form was submitted, using header()? Thanks for your help, Ben.
0
2790
by: mcp6453 | last post by:
I am trying to use Jack's FormMail script (http://www.dtheatre.com/scripts/formmail). Since I'm brand new at PHP and not very good at HTML, I have an easy question, which I will narrow down. When the email arrives, it has this information: v_firstname: asdf v_lastname: asdf b_email: asdf@bellsouth.net v_phone: asdf v_cellphone: asdf
8
5457
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I...
6
4967
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a...
2
4278
by: dalsoth | last post by:
Hi Guys I have created a website and to makes things easier i decided to use dreamweaver to do the secure login section and access levels for the pages. When testing locally on wamp my website works perfectly. On internet though, the pages that don't require a user to log in i can search my job database perfectly and see the results so the...
1
1406
tolkienarda
by: tolkienarda | last post by:
hi all i seem to be having a problem with session variables, and registering sessions. i am runing wamp5 and i think that i need to change something in the php.ini file cause i basicaly coppied the code from a login script that works on my server(php v4.somthing) so i think the problem is v5. following is the code from login.php. <?...
8
3019
by: Eddie | last post by:
I am having difficulty in setting variables in a session, and then accessing those variables throughout the web pages that they click on. After having them set a user name and password, successfully authenticating against Active Directory, I send them from the login.php page to the index.php page. But when I get to the index.php page, the...
1
2922
by: vikjohn | last post by:
I have a new perl script sent to me which is a revision of the one I am currently running. The permissions are the same on each, the paths are correct but I am getting the infamous : The specified CGI application misbehaved by not returning a complete set of HTTP headers. The scripts are very long but here are the opening statements: The One...
6
9450
by: Ramon | last post by:
Is there a way to initialize the variables (or other data) of a header file by using a function (similar to main() function)?? Thankx
0
7455
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7962
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7480
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7814
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5373
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3504
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.