Connecting Tech Pros Worldwide Help | Site Map

HELP: Form and PHP

Steven
Guest
 
Posts: n/a
#1: Jul 16 '05
Hello,

I used a form to collect some data, and then use php script to verify the
data before send it to database. If the php script found some errors in
input data, it will use header(Location:register.php) to send it back to the
same form page.

Is there a way to keep those valid data and only ask user to input the data
with errors?

Thanks
-Steven



R. Rajesh Jeba Anbiah
Guest
 
Posts: n/a
#2: Jul 16 '05

re: HELP: Form and PHP


"Steven" <xueming@attbi.com> wrote in message news:<jdSLa.62264$Fy6.16960@sccrnsc03>...[color=blue]
> Hello,
>
> I used a form to collect some data, and then use php script to verify the
> data before send it to database. If the php script found some errors in
> input data, it will use header(Location:register.php) to send it back to the
> same form page.
>
> Is there a way to keep those valid data and only ask user to input the data
> with errors?[/color]

You can look at this example: agriya.com/demo/sendmore/signup.php

I will tell you the logic of the code....

<?php
//main.php
$var1=$var2="";//reset

if ($_POST)
{
if (form data is valid)
{
addformdata();
echo "success";
}
else
{
//fetch the values from $_POST....
$var1 = $_POST['var1'];
$var2 = $_POST['var2'];
include("template.php"); //show the template file
}
}
else //first time visit
include("template.php"); //show the template file
?>


<?php
//template.php
echo $var1;
echo $var2;
?>

In the template.php file, you actually will have the form stuff...

I have done it with class modules---it really saved lots of time.

HTH,
R. Rajesh Jeba Anbiah

---
"War kills you and me!"
Email: rrjanbiah-at-Y!com
Closed Thread