Author Topic: Sending $_POST vars back to the form page??  (Read 211 times)

0 Members and 1 Guest are viewing this topic.

Offline PerfidusTopic starter

  • Enthusiast
    • View Profile
Sending $_POST vars back to the form page??
« on: March 20, 2009, 10:45:02 AM »
Hello there !
I'm sending a big a form to be stored in DDBB, after storing the user is headed by header(location:"whatever.php") to a wellcoming page, but whenever is an error on the mysql query and datas can't be stored on DDBB, I would like the user to be sended back to the form page and to find all the fields already filled by reusing the $_POST[] vars.
Is it possible? Can $_post[] array be re-sended?

Offline premiso

  • Life is too short
  • Freak!
  • Gender: Male
  • Liquid luck is Jack Daniel's
    • View Profile
Re: Sending $_POST vars back to the form page??
« Reply #1 on: March 20, 2009, 10:46:17 AM »
Put the data into session and check if the session isset if it is put that variable back in the box.

Offline PerfidusTopic starter

  • Enthusiast
    • View Profile
Re: Sending $_POST vars back to the form page??
« Reply #2 on: March 20, 2009, 11:24:30 AM »
That's a good point, but remember form is a big one with several textareas, wont this be too much for $_SESSION vars?
Can I store the array itself as a $_SESSION var rather than every single var one by one?

Offline premiso

  • Life is too short
  • Freak!
  • Gender: Male
  • Liquid luck is Jack Daniel's
    • View Profile
Re: Sending $_POST vars back to the form page??
« Reply #3 on: March 20, 2009, 11:28:45 AM »
Sessions are stored on a file on the server. It can hold massive amounts of data without worry. Plus it is all text, I take it, and text holds no space at all.

You can store it in the session as an array or as individual vars, it is up to you.

Offline PerfidusTopic starter

  • Enthusiast
    • View Profile
Re: Sending $_POST vars back to the form page??
« Reply #4 on: March 20, 2009, 01:54:39 PM »
Thanks a lot Premiso, I'm going to put my hands on it now !

Offline mrMarcus

  • Devotee
  • Gender: Male
  • 2009/10 Stanley Cup Champions.
    • View Profile
Re: Sending $_POST vars back to the form page??
« Reply #5 on: March 20, 2009, 04:30:00 PM »
you just need some better error handling.

only have the user redirected upon a successful database query.

if the query is a success, redirect...if not, back to the form they go.

will save all that other unnecessary business.

Offline mrMarcus

  • Devotee
  • Gender: Male
  • 2009/10 Stanley Cup Champions.
    • View Profile
Re: Sending $_POST vars back to the form page??
« Reply #6 on: March 20, 2009, 04:34:57 PM »
oh, and in your form input fields be sure to have something like this...

Code: [Select]
<input type="text" name="whatever" value="<?php echo $_POST['something']; ?>" />
that way, when the user is back at the form, any inputted values will be present in the input field's.

you can do textarea as well.

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.