NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Contact Form Help

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-18-2006, 01:10 PM THREAD STARTER               #1 (permalink)
Pimp Master M
Join Date: Apr 2006
Posts: 51
DJL2K is on a distinguished road
 



Contact Form Help


Okay, so I've got a contact form for my portfolio. The code looks alright but the form won't send the emails that are submitted
contact.php
PHP Code:
<?php
$youremail 
"matt@matt-license.com";
$subject $_POST['subject'];
$thankyou "Thank you. Your Email has been sent; I'll try to respond ASAP.";

while(
$_POST['submit']) {
    if( 
$email == "" ) {
        echo(
"<tr><td colspan='2' style='text-align:text-align:center; '>No email address added. Please go back.<br/></td></tr>");
        }
    elseif(
$name == "") {
        echo(
"<tr><td colspan='2' style='text-align:text-align:center; '>No name added. Please go back.<br/></td></tr>");
        }
    elseif(
$message == "") {
????: NamePros.com http://www.namepros.com/programming/229089-contact-form-help.html
        echo(
"<tr><td colspan='2' style='text-align:text-align:center; '>No message added. Please go back.<br/></td></tr>");
        }
    else {
        
$msg ereg_replace("\\\'""'"$message);
        
$msg ereg_replace('\\\"'"\""$msg);
????: NamePros.com http://www.namepros.com/showthread.php?t=229089
        
$message1 "from: $name<br />email: $email<br />message:<br />$msg1";

        
mail($youremail$subject$msg"From: $email\r\nReply-to: $email\r\n");
        echo(
"<tr><td colspan='2' style='text-align:text-align:center; '>$thankyou</td></tr>");
        }
    }
?>
</table>
</form>
Click here to see what is doing
DJL2K is offline  
Old 08-18-2006, 02:47 PM   #2 (permalink)
NamePros Member
 
Man In The Box's Avatar
Join Date: Aug 2006
Location: Canada
Posts: 34
Man In The Box is an unknown quantity at this point
 



You don't need a while loop, you can use the isset() function with an if statement. For example:

Code:
if(isset($_POST['submit']))
{
     //Other code
}
Now the problem lies in the mail function. You need to specify the user's email address, not yours.
????: NamePros.com http://www.namepros.com/showthread.php?t=229089

Code:
mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
The bolded part should not be $youremail, but the variable $email (or $_POST['email']) since that represents the contacter's email address.
Man In The Box is offline  
Old 08-18-2006, 02:59 PM   #3 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
The script is supposed to send it to him. He has it right.

PHP Code:
<?php
$youremail 
"matt@matt-license.com";
$subject $_POST['subject'];
$thankyou "Thank you. Your Email has been sent; I'll try to respond ASAP.";

if(
$_POST['submit']) {
    
$email $_POST['email'];
    
$name $_POST['name'];
    
$message $_POST['message'];
    if( 
$email == "" ) {
        echo(
"<tr><td colspan='2' style='text-align:text-align:center; '>No email address added. Please go back.<br/></td></tr>");
        }
    elseif(
$name == "") {
        echo(
"<tr><td colspan='2' style='text-align:text-align:center; '>No name added. Please go back.<br/></td></tr>");
        }
    elseif(
$message == "") {
        echo(
"<tr><td colspan='2' style='text-align:text-align:center; '>No message added. Please go back.<br/></td></tr>");
        }
    else {
        
$msg ereg_replace("\\\'""'"$message);
????: NamePros.com http://www.namepros.com/showthread.php?t=229089
        
$msg ereg_replace('\\\"'"\""$msg);
        
$message1 "from: $name<br />email: $email<br />message:<br />$msg1";
        
$headers 'From: ' $email "\r\n" .
                   
'Reply-To: ' $email "\r\n"
        
mail($youremail$subject$msg"From: $email\r\nReply-to: $email\r\n");
        echo(
"<tr><td colspan='2' style='text-align:text-align:center; '>$thankyou</td></tr>");
????: NamePros.com http://www.namepros.com/showthread.php?t=229089
        }
    }
?>
</table>
</form>
Dan is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 06:08 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger