FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


HomeWatched TopicsRegisterSearchDirectory
FAQMemberlistUsergroupsLog inStoresItemsBank
Google

Reply to topic Page 1 of 1
question about header and validation
Message  

Reply with quote
Post question about header and validation 
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 " <form name='errorpage' action='error.php' method='post'> </form>       
       <script type='text/javascript' language='javascript'> document.errorpage.submit(); </script> ";
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.

View user's profile Send private message

Reply with quote
Post  
Hi!

For the first situation I would advice you to use fopen() function:

Code:

<?php
$handle = fopen("filename.html", "rb");
$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192);
}
fclose($handle);
echo $contents
?>



for the second problem:

a. Try this:

$specialcharacters = '#^([a-zA-Z0-9]+[\040]*[a-zA-Z0-9]*)$#'

b. did not understand what you meant.


_________________
www.eb-downloads.com
FREE E-BOOKS DOWNLOADS.
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

Reply with quote
Post why echo before a redirect? 
Not sure what kind of important information needs to *not* be displayed before you redirect the user to another page through echo statements.

typically you want to redirect a user based on a case scenario:

if ($activity == "passed the scenario") {
     // send them on their way with the redirect.
} else {
    // echo the statements they should see instead.
}


_________________
somewhere a clock is ticking...
View user's profile Send private message Visit poster's website

Reply with quote
Post  
$specialcharacters = '#^([a-zA-Z0-9\s]+)$#';

\s for space.

So it looks for letters numbers and spaces. Anything else is ignored.

$firstnamecheck = '/^[a-zA-Z\s]+$/';

Same.


_________________
http://www.linkedin.com/in/khokchin
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  



Google

FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


Web Design by PlatinumShore.com & Web Hosting by TradeWebHosting.com