Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-04-2006, 03:56 AM   #1 (permalink)
jpmad4it
Recruit
 
Join Date: Feb 2006
Posts: 3
jpmad4it is on a distinguished road
Form processing question

hello people,

Im new here - Hello!!!

I have a HTML form that passes data (post) to a PHP script. Now, at the moment the script checks to see if all fields are filled out, or whether the email address is valid and whether the image verification is valid. The problem is that when the error message is displayed there is a javascript:history back button that the user clicks to take them back. Once they go back all the data they originally posted has disappeared. This is very annoying. How do i make the form 'remember' the information already posted. Someone alreadt mentioned that i can post the values to the apge itself - but i never really understood where they were coming from.

The only way i can think of getting around this is by making the PHP script display the correct/valid information submitted, and if there are any errors it highlights this and allows the user to correct the problems using another form field and re-submit the information.

can anyone guide me of what i need to do here?

regards Jonathan
jpmad4it is offline   Reply With Quote
Old 02-04-2006, 07:11 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,486
sde is on a distinguished road
you could try saving the info in a session. for example:
PHP Code:
<?
session_start
();

if( 
$_POST] ) {
  
$_SESSION['usename'] = $_POST['username'];
  
// do all your other stuff
}

// then on the form, the input boxes would look something like this
?>
<input type=text name=username value="<?=$_SESSION['username']?>">
then no matter where you take them, .. when they go back to the form page, those values will be there by default. i would clear out the session values once the form goes through successfully though.

if you can, do your validation client side and you won't have to deal with this. but if you need to go server side, and the form action is a different page than the form, then you'lle probably have to use this.

if your action page is the same page as the form, then you can just do something like this:
PHP Code:
<input type=text name=username value="<?=$_POST['username']?>">
sde is offline   Reply With Quote
Old 02-04-2006, 07:34 AM   #3 (permalink)
jpmad4it
Recruit
 
Join Date: Feb 2006
Posts: 3
jpmad4it is on a distinguished road
im not too keen on the sessions - i can never seem to get them to work right
jpmad4it is offline   Reply With Quote
Old 02-04-2006, 07:42 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,486
sde is on a distinguished road
well you've come to the right place. welcome to codenewbie. if there's something you want to learn, there is pleanty of patience and knowledge in the PHP area for it around here.

if you can, post the relevent pieces of your code, .. a form with a couple fields, and a small piece of the page that is processing your form. i'm sure you'lle get some good feedback.

i'm on my way out the door, but i'll check in later.
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Child Form to Parent Form WmFenn MS Technologies ( ASP, VB, C#, .NET ) 2 07-20-2005 08:10 AM
Generate query automatically from form phase PHP 1 04-06-2005 01:11 AM
Passing Values from Popup Form to Main Form chrislopezz PHP 7 03-28-2005 12:45 PM
form processing? falsepride Platform/API C++ 11 01-28-2005 12:31 PM
EMERGENCY: Dynamic form processing DavH27 PHP 8 10-27-2004 07:52 PM


All times are GMT -8. The time now is 04:25 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting