Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-23-2010, 07:22 AM   PM User | #1
ajloun
Regular Coder

 
Join Date: Aug 2009
Posts: 215
Thanks: 74
Thanked 0 Times in 0 Posts
ajloun has a little shameless behaviour in the past
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
ajloun is offline   Reply With Quote
Old 01-23-2010, 07:38 AM   PM User | #2
Len Whistler
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
Len Whistler is on a distinguished road
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
Len Whistler is offline   Reply With Quote
Old 01-23-2010, 10:03 AM   PM User | #3
seco
Regular Coder

 
seco's Avatar
 
Join Date: Nov 2008
Location: Oregon
Posts: 682
Thanks: 5
Thanked 79 Times in 77 Posts
seco has a little shameless behaviour in the past
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.
seco is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:39 AM.


Advertisement
Log in to turn off these ads.