Posted by Jerim79 on 11/17/06 20:49
e_matt...@hotmail.com wrote:
> > Here is the basic gist of what I have:
> >
> > <?php
> > $FName=$_Post['FName'];
> >
> > if ($FName !=""){
> > header("Location: write_to_database.php");
> > }
> > else{
> > if ($FName=""){
> > $errormsg1="Please enter a first name":
> > }
> > ?>
> >
> > <html>
> > <body>
> > Registration
> > <?php if ($errormsg1 !="") echo $errormsg1); ?>
> > <br />
> > <form action="(this page)"
method="Post">
> > First Name: <input type="text" name="FName">
> > <br />
> > <input type="submit" name="submit value="Submit">
> > </form>
> > </body>
> > </html>
> >
> > Forgetting the problem about loading the errors up before filling out
> > the form, I can't get this to work at all. After I click on submit it
> > just brings me back to the same page, with no error messages.
>
> Try:
> <?php
>
> $FName = "";
> $errorMsg1 = "";
>
> if ($_POST) {
>
> if ( isset($_POST['FName']) ) {
> $FName = $_POST['FName'];
> }
>
> Now you can validate $FName, because it's either empty or set to
> user's value. Don't write to database without validating all data.
> The rest looks good. Good luck.
Since I am still learning, I just wanted state the logic of the code.
First we set $FName equal to nothing. Then we set $errorMsg1 equal to
nothing. Next we say "if the method is $_POST" then check to see if
$_POST['FName'] has been set. If it has, then set $FName equal to
$_POST['FName']
I still can't get it to display the error message.
[Back to original message]
|