Re: Will this work?

From: Date: Mon, 19 Feb 2001 21:25:58 +0000
Subject: Re: Will this work?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-40633@lists.php.net to get a copy of this message
Ok, I removed the (" ") from action and it worked, but it doesnt validate, just sends to thanks page regardless of whether the fields are filled or not. Am I mistaking IsSet for handling that? > 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 _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com

« previous php.general (#40633) next »