homepage Welcome to WebmasterWorld Guest from 54.161.166.171
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Two forms on page. Must save both forms regardless of where user goes.
Logistics form flow
salewit




msg:4014712
 4:10 am on Oct 28, 2009 (gmt 0)

I have a shopping cart page that displays the cart contents, and needs to allow customers to OPTIONALLY change shipping type AND/OR OPTIONALLY leave a comment.

So here's the very simplified code:


<?php
if (isset($_POST['shipchoice'])) {
$shipchoice = $_POST['shipchoice'];
}
?>
<html, etc...>
<!-- Display cart here with shipping method selected -->
<form method="post" name="shipping" action="<? echo $_SERVER['PHP_SELF']; ?>">

<p>Select desired shipment method:
<input type="radio" name="shipopt" value="1st Class Mail" onclick="this.form.submit();";
<input type="radio" name="shipopt" value="Media Mail" onclick="this.form.submit();";
<input type="radio" name="shipopt" value="Priority Mail" onclick="this.form.submit();";

</form>
<form method="post" name="done_make_payment" action="authorize_payment.php">

<p>Enter any special requirements or comments:
<textarea name="comment"><? echo $_SESSION['comment']; ?></textarea>

<input type="submit" value="Make Payment">
</form>

In authorize_payment.php:


<?php
$_SESSION['comment'] = CleanFilter($_POST['comment']);

So if you follow what's happening. A person *could* change the shipping method. If they do that, the form is refreshed, and the cart is displayed with that new ship method. No problem there. They could also leave the shipping method as it was, and add a comment and authorize the payment. No problem there either. BUT if a person leaves a comment, then decides to also change the shipment method, that comment then disappears and they are forced to enter it again.

I really don't want to split this into two pages, and it's absolutely necessary that these two options are given. This is actually a page from a PayPal Express payment. The customer accesses PayPal, PalPal sends them to this page after verification, then this page sends the data to PayPal to finalize it.

I hope I didn't make this more complicated than it is.

 

TheMadScientist




msg:4014733
 5:16 am on Oct 28, 2009 (gmt 0)

I don't understand what you're doing well enough to really make much of a suggestion, except use a bit of AJAX to update the cart rather than refreshing the page to change the selection value of the form... Otherwise I'll have to understand the system a bit better, because I'm sure there's a reason, but I can't see why you need to have the two forms, or at least the entry sections separated.

IMO You could easily use AJAX to update anything you are updating with a full page refresh (form submission), but I really don't understand what you are doing very well.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved