HELP: Form and PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steven

    HELP: Form and PHP

    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

    #2
    Re: HELP: Form and PHP

    "Steven" <xueming@attbi. com> wrote in message news:<jdSLa.622 64$Fy6.16960@sc crnsc03>...[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("templa te.php"); //show the template file
    }
    }
    else //first time visit
    include("templa te.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

    Comment

    Working...