Re: New to PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is the basic way I do most of my forms.  You can also extend this 
to use database values instead of the post values for the first time the 
form loads.  Have fun.

<?php
// initialize your message
$msg = '';
// are you coming from a posted form?
if (isset($_POST['myfield'])) {
    //set error conditions
    if ($_POST['myfield'])=='') {
        $msg = 'Please enter a valid value for myfield';
    }
    //if there are no error conditions
    if ($msg == '') {
        //do whatever you want with the data
        //.....
        //and then go somewhere else
        header('location: done.php');
    }
}
//if this was not a form post or we had an error, we fall through to here
if ($msg!='') {
    echo 'Error: ' . $msg . '<BR>';
}
?>
<form action="thispage.php" method="post">
<input type="text" name="myfield" value="<?=(isset($_POST['myfield']) ? 
$_POST['myfield'] : '')?>">
<input type="submit" class="button" name="Submit" value="Submit">
</form>


bhaskargara wrote:

>I am new to PHP. 
>
>    I have a Sign up screen. if user didn't filed the required fields 
>I have to reload the same form with message. 
>
>    How do I reload the same form. I am able to validate the message.
>
>Thanks
>Bhaskar
>
>
>
>
>
>
>
>
>PHP Data object relational mapping generator
>http://www.metastorage.net/ 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>
>  
>



PHP Data object relational mapping generator
http://www.metastorage.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux