Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Two forms on page. Must save both forms regardless of where user goes.

Logistics form flow

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

Junior Member

10+ Year Member

joined:June 12, 2004
posts: 119
votes: 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:

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 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">

In authorize_payment.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.

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

Senior Member from US 

WebmasterWorld Senior Member themadscientist is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 14, 2008
votes: 62

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.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members