Page 1 of 1

PHP mail function submission issue

Posted: Tue Mar 02, 2010 8:14 pm
by eraewket
I have an issue with a site that I use the mail function with. On my site, when the user finds the item they want, they click the link which opens that a detailed page about that item. Once they provide their email address, they submit the form and an email is sent to the user of that item. However, every time that a user opens the page, refreshes or goes back on the page, the email is sent from the server. How do I avoid this and just get the email to submit when the user actually submits? Here is the code:

$Seller = mysql_query("SELECT SellersEmail FROM Books_for_Sale WHERE BookNumber = ".$_REQUEST['BookNumber']);
$Seller = mysql_result($Seller, 0);
$Buyer = $_POST['BuyersEmail'];
$subject = "Congratulations, someone would like to buy your book!";
$message_query = mysql_query("SELECT CONCAT('$', Price) AS 'Price', Title, Author1, Author2, Author3, Version, Edition, ISBN, BookNumber, CONCAT(SubjectArea,' ', CourseNumber) as 'Course Number' FROM Books_for_Sale WHERE BookNumber = ".$_REQUEST['BookNumber']);
$message = $_POST['BuyersFirstName']." ".$_POST['BuyersLastName']." "."would like to buy your book:"
."\r\n"." "."\r\n".
"Title: " .mysql_result($message_query, 0, "Title")."\r\n".
"Author(s): ".mysql_result($message_query, 0, "Author1")."\r\n".
" ".mysql_result($message_query, 0, "Author2")."\r\n".
" ".mysql_result($message_query, 0, "Author3")."\r\n".
"Version: ".mysql_result($message_query, 0, "Version")."\r\n".
"Edition: ".mysql_result($message_query, 0, "Edition")."\r\n".
"ISBN: ".mysql_result($message_query, 0, "ISBN")."\r\n".
"Course Number: ".mysql_result($message_query, 0, "Course Number")."\r\n".
"Price: ".mysql_result($message_query, 0, "Price")."\r\n"." "."\r\n".""
.$_REQUEST['BuyersMessage'];
mail($Seller, $subject, $message, "From: $Buyer\r\nReply-To: $Buyer");

Re: PHP mail function submission issue

Posted: Wed Mar 03, 2010 2:47 am
by rmrbest
Can you check form with isset($_POST['submit']) ?