Tech Support Guy banner
Status
Not open for further replies.
1 - 2 of 2 Posts

·
Registered
Joined
·
117 Posts
Discussion Starter · #1 ·
1.
i have a question about using header("Location: filename.html"); in php

with my present code i have a few echo statements followed by header("Location: filename.html"); because i have echo

statements before header("Location: filename.html"); i am getting an error that headers have already been sent. i cannot

remove the echo statements as they are doing an important task. based on this situation i can use echo followed by the html

code for the filename in filename.html if i do this the code will run into a few 100's of lines and due to this i would like

to use header("Location: filename.html");

i have tried the following code and it works =

echo "
";
however if javascript is turned off this redirection will not work.

could you please suggest if there is an alternative to using echo statement first followed by
header("Location: filename.html");

2.
i am using the following php validation for forms which is not working very well

a)
$specialcharacters = '#^([a-zA-Z0-9]+)$#';
with this code for a name if i type "first name" with a space it is considering the space and treating as a special character

however it should validate for letters and numbers only. how can i write '/^[a-zA-Z]+$/'; to ignore spaces

b)
$firstnamecheck = '/^[a-zA-Z]+$/';
with this code if i type for example "first name" as per the error is states that the string needs to contain letters. though

i typed letters because of the space it is not treating as letters. how can i rewrite this '/^[a-zA-Z]+$/';

please advice.

thanks.
 

·
Registered
Joined
·
414 Posts
Hi,,

Why are you doing echos before the header command this is a No No. Header commands chnage the header information the server sends to the browser before the page is parsed. I.E. you coudl tell the browser that the page ocntents is actually an image not html, not that in this case that would help.

SO can we see you code, as there is probably a much better solution to this, than rearrangingthe echos and using an alternative to the header command. What is teh funciton of this header command and teh echos, we need a little more informaiton here.

Secondsly to ignore white spaces, at a rough guess i thin you need to use [^/s] this means not space.

Someone will need to confirm this as i am not 100% sure but try this '/^[^/s][a-zA-Z]+$/.

Harry
 
1 - 2 of 2 Posts
Status
Not open for further replies.
Top