Need Help With PHP Mail
Posted: Thu Apr 23, 2009 5:25 pm
Hi everyone,
I am very new to this forum and in desperate need of HELP! Please someone help! I have a code to allow users to become fans of a business. When they click the submit button I want the info inserted in the database and an email sent to the business saying that they have a fan. The problem is when I added the code to detect that the submit button was clicked, the info is sent to the database but email not sent. When i excluded the code, an email is sent to the business every time the page loads and whether or not the submit button is clicked. Please, please help...I only want it sent when the button is clicked...help anyone?
My form code is below:
Thanks in advance!
I am very new to this forum and in desperate need of HELP! Please someone help! I have a code to allow users to become fans of a business. When they click the submit button I want the info inserted in the database and an email sent to the business saying that they have a fan. The problem is when I added the code
Code: Select all
if (isset($_POST['yourfan']))Code: Select all
<form action="<?php echo $editFormAction; ?>" method="POST" name="fan" id="fan">
<input name="yourfan" type="image" value="Submit" onClick="<?php
if (isset($_POST['yourfan']))
{
$to = $row_Bus['Email'];
$subject = 'You Have A Fan !';
$body = "blah...blah...blah.... ";
$headers = "From: admin@mysite.com\r\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \n";
$mail_sent = @mail( $to, $subject, $body, $headers );
}
?>;MM_popupMsg('It\'s official! You are now a fan.')" src="/FANBUT2.png" alt="Become A Fan"/>
</label>
<input type="hidden" name="MM_insert" value="fan" />
</form>