FORMS

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lloydsmods
Forum Newbie
Posts: 22
Joined: Wed Aug 14, 2002 2:03 pm
Location: NC

FORMS

Post by lloydsmods »

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:

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

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>
This then passes my data to contact2.php which does the following:

Code: Select all

$web = "webmaster@yoursite.com";
$service = "service@yoursite.com";

if($to == 'Webmaster')
&#123;
   mail($web, "$subject from $name at $email", "$question");
&#125;

else
&#123;
   mail($service, "$subject from $name at $email", "$question");
&#125;

echo "<br>Thank you for your comments <b>".$name."</b> I appreciate your message.  Click <a href="index.php">Here</a> to continue browsing.";
?>
Thats what should happen in theory. When you hit SUBMIT, it opens your PayPal shopping cart. Any ideas?
Post Reply