Posted by e_matthes on 11/17/06 20:36
> 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.
Navigation:
[Reply to this message]
|