Simple form elements question!

This is a discussion on "Simple form elements question!" within the PHP Forum section. This forum, and the thread "Simple form elements question! are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 18th, 2007, 13:17
New Member
Join Date: Jul 2007
Location: England
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Simple form elements question!

Say i have a multipage form and the user fills in page 1 then goes to page 2 and fill some more in.

Then say they want to go back to page 1 to change some details, so page 1 needs to still have all the form entries they made.

What i would like to know is, when generating the form elements, should i do a if statement that populates the value of the element from POST array if there is any data in it otherwise the value is empty.

Is that the best / right way of doing it?

Any help would be really appreciated!
Reply With Quote

  #2 (permalink)  
Old Jul 18th, 2007, 14:30
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Blake121
Re: Simple form elements question!

I think the best way to do it would be with sessions.

That way you can the data will be accessible throughout the entire form.

PHP: Select all

<?php session_start() //start session to allow session cookies

if(array_key_exists('submit_form'$_POST)) { //check if forms posted
 
 
$_SESSION['form'] = array('field_one' => $_POST['field_one'], 'field_two' => $_POST['field_two']); //place $_POST's in session array

//replace field_one etc. with your filed names.

}
?>
Do something like that.

Then for the form...

Code: Select all
<input type="text" name="field_one" value="<?php if(isset($_SESSION['form']['filed_one'])) { echo $_SESSION['form']['filed_one']; } ?>" />
Reply With Quote
  #3 (permalink)  
Old Jul 18th, 2007, 14:37
Up'n'Coming Member
Join Date: Jul 2007
Location: France
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Simple form elements question!

Is there any reason why the form has to be on several pages? Could it be on one long page, suitably divided and presented? That way the user wouldn't be making the problem that you've then got to code for.

I'm thinking more of a logical approach than a design approach.

Just a thought.
Reply With Quote
  #4 (permalink)  
Old Jul 18th, 2007, 14:54
New Member
Join Date: Jul 2007
Location: England
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Simple form elements question!

Well yes it could be on one page i think.

What it does is takes some form inputs and makes some calculations from those inputs, the results of the calculations are then displayed on the next page.

If the results aren't what the user wants, they can go back and change the form entries and then submit again which recalculates, if the results are what they want, they can go on and add some more info and so on and so forth.

Perhaps i need to have the form on one page but fold it up into tabbed pages with some ajax. Then i need to work out how, using ajax, to do the calculations in real time, but let the user go back and forth between tabbed pages modifying and re-calculating.

I don't have much experience with ajax though, not sure how i would achieve the above!
Reply With Quote
Reply

Tags
forms populate

Thread Tools

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
First Hello - and a simple FORM question webhead Introduce Yourself 4 Apr 7th, 2008 18:02
[SOLVED] Simple form submission question future448 JavaScript Forum 2 Oct 14th, 2007 09:35
Drop down form elements 1840dsgn Web Page Design 3 Sep 4th, 2007 19:09
Disabling/Enabling form elements flamin_mongrel JavaScript Forum 1 Oct 18th, 2006 21:51
download browser screenshots, form elements and buttons neckcns Graphics and 3D 0 Dec 23rd, 2005 16:24


All times are GMT. The time now is 22:12.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43