Jump to content

Passing $_POST data without a submit button?


vozzek

Recommended Posts

Hi all,

 

I've got a checkout page on my website that contains $_POSTed information from the previous page (shipping and billing address).  The page also shows the user's shopping cart, by looping though one of my mySQL tables.

 

On this page, I have a form that allows the user to add a gift certificate to the cart.  A radio button selects the denomination, and they click submit.  From here, I launch into another .php page to do some SQL checks and updates.  Once done, I'd like to automatically return to the checkout page... but now, I need to re-pass the previously $_POSTed data.

 

Is there an automatic way to pass this data from page 1, to page 2, and then back to page 1 again - without a 'submit' button?  That's my first question.

 

Second question:  Is there an easier/better way to do this that doesn't include AJAX  ;)  I know I could write the php code to do the SQL stuff right on the checkout page, but in order for the shopping cart to show the newly added gift certificate it would have to do an automatic page update when done.  I don't want the user to see a "RE-POST FORM DATA?" question pop up and then have to click "OK" - that's just sloppy.  (Perhaps there's a command to automatically re-post form data when the page loads that I don't know about yet?)

 

Anyway, any advice on this would be greatly appreciated.  I've found a hell of a lot of help on these boards from some real savvy people - you guys rock, and I mean that.

 

Thanks.

 

Link to comment
Share on other sites

Sessions.

You can do

index.php
<?
session_start();
$_SESSION['varname'] = "data";
$_SESSION['address'] = "11111 blue street";
?>

page2.php
<?
session_start();
echo $_SESSION['varname'] . " " . $_SESSION['address'];
?>

data 11111 blue street

 

Check the php website for more info

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.