Log in

View Full Version : need help with an if else statement



jefflong
02-10-2011, 08:28 AM
Hello community

I am having some troubles with the following statement:


<?php


if (isset($_POST["checkout"])) {
//button 1 action
echo "<form action='https://www.paypal.com/cgi-bin/webscr' name='order' method='POST' onsubmit='return ReadForm(this, true)'>";
}
elseif (isset($_POST["update"])) {
//button 2 action

print " <br>NAME: <b>".$_POST['name']."</b><br> EMAIL: <b>".$_POST['email']."</b><br>Address: <b>".$_POST['address']."</b><br>City: <b>".$_POST['city']."</b><br>Postal Code/Zip Code: <b>".$_POST['postal']."</b><br> ";
print "ORDER:<br/>";
foreach ($order as $f) {
echo $f."<br />";
}

}

else {
}
?>

Bassically the first button should send the info to paypal, and the second button updates a list so the person can see what they have in their cart without going to paypal. The second button works fine, but checkout simply does nothing. I've been staring at this for hours and am out of ideas. If anyone knows of a solution that would be great.

Let me know if I need to add anything else.

Thanks in advance

Schmoopy
02-10-2011, 05:47 PM
Can you post all of the code?

The code below only echoes out a form tag. Where's the actual submit button for the form?


if (isset($_POST["checkout"])) {
//button 1 action
echo "<form action='https://www.paypal.com/cgi-bin/webscr' name='order' method='POST' onsubmit='return ReadForm(this, true)'>";
}


Edit: Might be worth looking at the ReadForm() function. If it returns false then your form's not going to get sent off.