| PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >> |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|
#1 (permalink) |
|
Registered User
Fresh Surpasser
Joined in Mar 2005
5 posts
Gave thanks: 0
Thanked 0 times
|
Email from form sending twice
The following form and PHP is resulting in 2 seperate emails... one that is formatted properly with the relevant information, and a second, blank email with "Unknown Sender" as the address. Could use some help with the code:
FORM Code:
<form method="post" action="sendemail.php"> <strong>Name:</strong> <input name="sender" type="text" style="margin-bottom: 5px;" /><br /> <strong>Subject:</strong> <input name="subject" type="text" style="margin-bottom: 5px;" /><br /> <strong>Your Email:</strong> <input name="email" type="text" style="margin-bottom: 5px;" /><br /><br /> <strong>Message:</strong><br /> <textarea name="message" rows="15" cols="40"></textarea><br /> <input type="submit" value="submit" /> </form> Code:
<?php
$subject = $_POST['subject'];
$message = $_POST['message'];
$from = "From: ".$_POST['sender']." <".$_POST['email'].">";
$to = "xxxx@xxxx.com";
$mail_success = mail($to, $subject, $message, $from);
if ($mail_success == true) {
echo '<strong>Thank you. Your email was sent successfully.</strong>';
} else {
echo '<strong>Error sending mail. Please try again.</strong>';
}
?>
Last edited by M.C. McMic; April 23rd, 2007 at 2:54 AM.. |
|
|
|
|
|
#2 (permalink) |
|
Race Surpass
Super #1
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,222 posts
Gave thanks: 18
Thanked 86 times
|
Might try the following instead:
PHP Code:
__________________
|
|
|
|
|
|
#3 (permalink) | |
|
Registered User
Fresh Surpasser
Joined in Mar 2005
5 posts
Gave thanks: 0
Thanked 0 times
|
Quote:
|
|
|
|
|
|
|
#4 (permalink) |
|
Registered User
Seasoned Poster
Joined in May 2005
67 posts
Gave thanks: 0
Thanked 2 times
|
Probably not the problem, but I do recall some bug in an earlier version of PHP (Possibly 4? I don't recall) where assigning a function to a variable and then checking that variable would result in the function being called twice or something weird.
Try: PHP Code:
|
|
|
|
|
|
#5 (permalink) | |
|
Registered User
Fresh Surpasser
Joined in Apr 2007
7 posts
Gave thanks: 0
Thanked 0 times
|
Quote:
__________________
sitting on SH116 : up.justadrunk.com |
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|