Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts

    retrieve data after click go back

    Hello

    I have a Post Form , the Process File Check if user typed His Name, Email, Text..

    Now if user post His Text and Forgot his Name or email He will be redierected to the form Page ,

    I want the User to retrieve the data he typed instaed Having to Start Over again ..

    How That Done ?

    Thank you

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Use SESSIONS or COOKIES. The value of each field would come from the SESSIONS or COOKIES, if empty then the field would be empty.









    ----------
    Leonard Whistler

  • #3
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts
    or jsut run the check in the same page.

    PHP Code:
    <?php

    $errors 
    = array();

    if (isset(
    $_POST['submit'])){

        
    $name  $_POST['name'];

        
    $email $_POST['email'];

        
    $phone $_POST['phone'];

        
    $question $_POST['question'];

        

        if(
    $name == ''){

            
    $errors[] = 'Please enter your name.';

        }

        if(
    $email == ''){

            
    $errors[] = 'Please enter your email.';

        }

        if(
    $phone == ''){

            
    $errors[] = 'Please enter your phone number.';

        }

        if(
    count($errors) == 0){

            
    //if no errors run this code you enter here.

        
    }

    }

    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <?php

            
    if(count($errors) > 0){

                echo 
    '<ul>';

                foreach(
    $errors as $e){

                    echo 
    '<li style="color:red;"><b>' $e '</b></li>';

                }

                echo 
    '</ul>';

            }

            
    ?>



    <form action="" enctype="multipart/form-data" method="post" id="yourform">
    <table cellpadding="0" cellspacing="0" border="0" width="500">
        <tr>
            <td width="150" valign="top">Full Name <span class="required">*</span></td>
            <td valign="top"><input name="name" id="name" type="text" size="25" maxlength="255"></td>
        </tr>
        <tr>
            <td width="150" valign="top">Email <span class="required">*</span></td>
            <td valign="top"><input name="email" id="email" type="text" size="25" maxlength="255"> </td>
        </tr>
            <tr>
            <td width="150" valign="top">Phone <span class="required">*</span></td>
            <td valign="top"><input name="phone" id="phone" type="text" size="25" maxlength="255"> </td>
        </tr>
            <tr>
            <td width="150" valign="top">Question <span class="required">*</span></td>
            <td valign="top"><textarea name="question" cols="25" rows="5"></textarea> </td>
        </tr>
        <tr>
            <td width="150">&nbsp;</td>
            <td valign="top"><input name="submit" type="submit" value="Send" /></td>
        </tr>
    </table>
    </form>
    </body>
    </html>
    This will check the form and if they miss a field it will show what they missed. This is a pretty straight forward way to do it. Just add your code you want to run on success.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •