PHP mail function submission issue

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
eraewket
Forum Newbie
Posts: 1
Joined: Tue Mar 02, 2010 8:08 pm

PHP mail function submission issue

Post 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");
rmrbest
Forum Newbie
Posts: 8
Joined: Fri Feb 26, 2010 2:32 am

Re: PHP mail function submission issue

Post by rmrbest »

Can you check form with isset($_POST['submit']) ?
Post Reply