Jump to content

I think I want a sticky form...


KevinM1

Recommended Posts

...but I'm not 100% sure how to implement it the way I want it to be implemented.  I'm writing scripts for my work's e-commerce side of things, and would like it if I could notify the user that their item has been added once they click "Add item to cart" (which will be a form submission button).  I'm just not sure how to do it with a sticky form.

I know how to make a generic sticky form -- check if the form's been submitted, and react accordingly.  I'm just concerned about the post-submit behavior.  Would something like the following work:
[code]
<?php

if(isset($_POST['submit'])){
  echo "$_POST['quantity'] of $_POST['name'] has been added to your cart!";
.
.
.
}

?>

<form...>
.
.
.
[/code]

If so, how would the end result be displayed?  Would the form not appear because it has been submitted, or would the order confirmation bit be displayed with the form?
Link to comment
Share on other sites

[code]

<?

if(isset($_POST['submit'])){  // this sees if the form is submitted if it has, then the echo shows the text about something has been added to the cart etc
     
    echo ".... has been added to your cart etc";  }  else { // This means if the form has NOT been submitted

echo "<form> .... </form>";  } [/code]

So  the first bit shows the added to cart text if the form has been submitted, then the second bit only shows the form , if the form has not been submitted. You will probly want to check other strings aswell before actually telling the user that the item has been added, like to see if an item id was submitted correctly etc.

                                          }
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.