You are here: Re: header() with if/then statements « PHP Programming Language « IT news, forums, messages
Re: header() with if/then statements

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация