FORMS
Posted: Tue Oct 01, 2002 1:36 pm
Okay, on my last post I mentioned that I'm working on a PHP/MySQL shopping cart for use with PayPal.
In the catalog listing I use this link to add an item to the PayPal shopping cart:
Now, this works fine (except for the glitch in the previous post). I also want a form to process e-mails. The form looks like this:
This then passes my data to contact2.php which does the following:
Thats what should happen in theory. When you hit SUBMIT, it opens your PayPal shopping cart. Any ideas?
In the catalog listing I use this link to add an item to the PayPal shopping cart:
Code: Select all
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="account">
<input type="hidden" name="item_name" value="$title">
<input type="hidden" name="item_number" value="12345">
<input type="hidden" name="amount" value="$price">
<input type="image" src="theme\addtocart.gif" border="1" name="submit" alt="Add to Cart" valign="center">
<input type="hidden" name="add" value="1">
</form>Code: Select all
<FORM METHOD=POST ACTION="contact2.php">
<table width="75%" border="1" cellspacing="5" cellpadding="5">
<tr>
<td>To</td>
<td colspan="2"><select name="to">
<option selected >Send Mail To:
<option>-----------
<option value="Service">Customer Service
<option value="Webmaster">Webmaster
</select>
</td>
</tr>
<tr>
<td>Your Name</td>
<td colspan="2"><input type="text" name="name"></td>
</tr>
<tr>
<td>Your e-Mail</td>
<td colspan="2"><input type="text" name="email"></td>
</tr>
<tr>
<td>Subject</td>
<td colspan="2"><input type="text" name="subject"></td>
</tr>
<tr>
<td colspan="3">Comments/Question</td>
</tr>
<tr>
<td colspan="3">
<textarea name="question" cols="60" rows="5"></textarea>
</td>
</tr>
<tr>
<td><input type="submit" value="submit"></td>
<td></td>
<td></td>
</tr>
</table>
</form>Code: Select all
$web = "webmaster@yoursite.com";
$service = "service@yoursite.com";
if($to == 'Webmaster')
{
mail($web, "$subject from $name at $email", "$question");
}
else
{
mail($service, "$subject from $name at $email", "$question");
}
echo "<br>Thank you for your comments <b>".$name."</b> I appreciate your message. Click <a href="index.php">Here</a> to continue browsing.";
?>