Web Design Forum: Store contents of form for use later - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Store contents of form for use later Rate Topic: -----

#1 User is offline   Colin 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 27
  • Joined: 01-April 09
  • Reputation: 0
  • Location:West Sussex
  • Experience:Advanced
  • Area of Expertise:Web Designer

Posted 24 July 2009 - 11:23 AM

I am developing a website that is basically a online directory. I would like the user to first fill in their details in a form then be moved to a payment page then go to a thank you and contents confirmation page then finally the contents of the form are inserted into a database.

I already have the form, I have the solution for the payment page and the final database insert. BUT what I don't know is how to temporally store the form contents for use in the final page.

I know I could ask for payment first than do the whole fill in the form and insert into the database in one go, I feel it is better for the user to fill in the form first then pay second.

The site is being developed in DreamWeaver using PHP and MySQL
0

#2 User is offline   Sam G 

  • Forum Newcomer
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,860
  • Joined: 06-March 09
  • Reputation: 54
  • Gender:Male
  • Location:Dreamland
  • Experience:Advanced
  • Area of Expertise:Designer/Coder

Posted 24 July 2009 - 12:23 PM

PayPal?
0

#3 User is offline   scaz182 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 365
  • Joined: 01-April 08
  • Reputation: 2
  • Gender:Male
  • Location:Reading UK
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 24 July 2009 - 06:38 PM

I'd use hidden form fields to pass the variables between pages.

<form>
/* payment form */
<input type="hidden" name="passed_data" value="<?php echo $_POST['data']; ?> /> // $_POST['data'] is from original form.
</form>


That can then be accessed in the subsequent page as $_POST['passed_data']

If however you don't have a form that you are able to adjust on your payment page you can stick the data in the URL and then reference it as a GET variable.
0

#4 User is offline   red-X 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 64
  • Joined: 28-October 08
  • Reputation: 0
  • Location:Eindhoven, Netherlands
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 24 July 2009 - 07:12 PM

use session variables :)
tutotial how to use sessions
0

#5 User is offline   Connetu_C 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 427
  • Joined: 12-December 08
  • Reputation: 25
  • Gender:Male
  • Location:London, UK
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 26 July 2009 - 11:16 AM

Be careful when moving between pages: very little is fool-proof. Here are two different approaches and what can go wrong. Firstly, you choose to use sessions (a generally but not 100% reliable mechanism). So (1) your user fills in their details and you store these in a session; (2) your user goes to the second page but sessions don't work and all their details are lost. Oops! Secondly, you choose to use hidden form fields, so (1) your user fills in their details which are then passed to the second payment page; (2) your user enters their payment details and hits OK; (3) a connection is made to the POST-back for the payment page and the payment is accepted; (4) their browser attempts to redirect to the confirmation page but their network is temporarily down. The result is they've paid but you have no record of what they've paid for because it hasn't been inserted in your database yet. Oops!

My first thought is to use sessions and to be careful that you aren't just relying on cookies to store the session ID. One solution is a hidden form field which stores the session ID between pages (rather than the entire set of details they entered, which is quickly going to make your pages and POST-backs overwhelmingly large). Then be careful that you only capture the payment in the final step, after the order details have been successfully added to your database. You can still authorise the payment at the second step to check all card details are correct etc. That combination of approaches should eliminate possible weak links in the chain.
0

#6 User is offline   skidz 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,047
  • Joined: 24-November 08
  • Reputation: 135
  • Gender:Male
  • Location:Derby
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 27 July 2009 - 10:54 AM

I've done this a few times with google and paypal. Sessions is my preffered method
0

#7 User is offline   Colin 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 27
  • Joined: 01-April 09
  • Reputation: 0
  • Location:West Sussex
  • Experience:Advanced
  • Area of Expertise:Web Designer

Posted 29 July 2009 - 06:14 PM

That really gives me something to work with - Thank you all. A friend mentioned using cookies. ie store the whole form in a cookie then retrieve the information from the cookie in the final confirmation page. This sound a similar solution to the session variable
0

#8 User is offline   sunwukung 

  • Expert
  • PipPipPipPipPip
  • Group: Validating
  • Posts: 1,150
  • Joined: 28-March 08
  • Reputation: 57
  • Gender:Male
  • Location:Bristol
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 29 July 2009 - 08:51 PM

There's a big difference between a cookie and a session. One of the best methods is to store the (preferably encrypted)session in a database temporarily and pull it back out when required. DON'T store your form details in a cookie...
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users