Re: Will this work?

From: Date: Mon, 19 Feb 2001 19:43:01 +0000
Subject: Re: Will this work?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-40619@lists.php.net to get a copy of this message
Hi, > <form method="POST" action="<?php print("$PHP_SELF"); > ?>"> > First Name: <input type=TEXT name="FirstName" size=15><p> > Last Name: <input type=TEXT name="LastName" size=25><p> > E-mail Address: <input type=TEXT name="Email" size=25><p> > <input type=SUBMIT> <input type=RESET> > </form> The form should work. > <?php > if(!IsSet($FirstName, $LastName, $Email)) > { > header("Location: http://www.SITE.com/error.php"); > exit; > } > else > { > header("Location: > http://www.SITE.com/thanks.php"); > exit; > } > ?> This won't work. I assume that this code is included on the page with the form above. First, the header() function must be called before any output is sent to the browser or it will throw an error and stop. The second problem is that the first time a user comes to this page, it will throw then to the error page because the vars won't be set. Try this: <? if($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST") { (!isset($Email)||!isset($FirstName)||!isset($LastName))? header("Location: http://www.SITE.com/error.php"): header("Location: http://www.SITE.com/thanks.php"); } ?> Then put your form below it. This will work unless you do a form post to this page from another page in which case it will throw you to the error page. Jason

« previous php.general (#40619) next »