Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP contact form problem
Old 02-22-2009, 02:36 AM PHP contact form problem
Experienced Talker

Posts: 40
Name: Abbas
Trades: 0
I've created a simple PHP contact form, and when I enter the information, I do receive the "Thank You For Your Email" message, but nothing is sent to my email. I'm using awardspace (the free version) for hosting, could it be a problem with my hosting plan?
Abbas22 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-22-2009, 03:01 AM Re: PHP contact form problem
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Its hard to tell what the problem might be without a look at your code.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-22-2009, 05:19 AM Re: PHP contact form problem
Joak1m's Avatar
Average Talker

Posts: 17
Trades: 0
As NullPointer said, you should show the source code first, but I'm 99 % sure, your hosting service has forbidden using mail() function, as most of the free services do.

Last edited by Joak1m; 02-22-2009 at 05:27 AM..
Joak1m is offline
Reply With Quote
View Public Profile Visit Joak1m's homepage!
 
Old 02-22-2009, 01:59 PM Re: PHP contact form problem
Experienced Talker

Posts: 40
Name: Abbas
Trades: 0
Here is my code

PHP Code:
<?php
if(isset($_POST['submit'])) {
$to "a_sadrossadat@yahoo.com";
$subject "Email From Site";
$name_field $_POST['name'];
$email_field $_POST['email'];
$message $_POST['message'];
 
$body "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

echo 
"Data has been submitted to $to!";
mail($to$subject$body);
} else {
echo 
"blarg!";
}
?>
Abbas22 is offline
Reply With Quote
View Public Profile
 
Old 02-22-2009, 02:46 PM Re: PHP contact form problem
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Your email does not contain any headers. At a minimum it should contain a from field.

Check out the documentation:
http://us.php.net/function.mail
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-22-2009, 03:12 PM Re: PHP contact form problem
Experienced Talker

Posts: 40
Name: Abbas
Trades: 0
I'm not quiet sure what you mean
Abbas22 is offline
Reply With Quote
View Public Profile
 
Old 02-22-2009, 03:52 PM Re: PHP contact form problem
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Take a look at the link I posted for more info, but in short the mail function has a fourth parameter additional headers. This is technically an optional parameter but without specifying from in the headers you message will not be sent.

PHP Code:
$headers "From: email@address.com \r\n";
mail($to$subject$body$headers); 
Headers can also be used to specify document type, include attachments, and add cc and bcc fields.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-22-2009, 03:54 PM Re: PHP contact form problem
GhettoFish's Avatar
Average Talker

Posts: 24
Name: Martin Söderberg
Trades: 0
I think he ment headers like this.

PHP Code:
$to 'nobody@example.com';
$subject 'the subject';
$message 'hello';
$headers 'From: webmaster@example.com' "\r\n" .
    
'Reply-To: webmaster@example.com' "\r\n" .
    
'X-Mailer: PHP/' phpversion();

mail($to$subject$message$headers); 
It looks like you are missing the message in your mail().

PHP Code:
$to "a_sadrossadat@yahoo.com"
$subject "Email From Site"
$name_field $_POST['name']; 
$email_field $_POST['email']; 
$message $_POST['message']; 
  
$body "From: $name_field\n E-Mail: $email_field\n Message:\n $message"
mail($to$subject$message$body); 
?> 
if you do it like that it might work. Or mail() isn't supported by your host.
__________________
“It is better to create than to be learned, creating is the true essence of life”
- Barthold Georg Niebuhr

Please login or register to view this content. Registration is FREE

Last edited by GhettoFish; 02-22-2009 at 03:55 PM.. Reason: code block error.
GhettoFish is offline
Reply With Quote
View Public Profile
 
Old 02-22-2009, 04:03 PM Re: PHP contact form problem
Experienced Talker

Posts: 40
Name: Abbas
Trades: 0
Thanks a lot guys, I tried all of your solutions but I'm still not receiving any emails.
I think the problem is my hosting plan, Thanks again.
Abbas22 is offline
Reply With Quote
View Public Profile
 
Old 02-24-2009, 10:48 PM Re: PHP contact form problem
anderswc's Avatar
Super Talker

Posts: 132
Name: Will Anderson
Location: Terre Haute, IN
Trades: 0
99.99999999% of free hosting providers don't allow PHP to send email because of spammers. If you really need to send email, you should by shared hosting somewhere. You can get it for around $5 a month (which is really quite cheap when you think about it).
__________________
Will Anderson

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
anderswc is offline
Reply With Quote
View Public Profile Visit anderswc's homepage!
 
Old 02-25-2009, 02:00 AM Re: PHP contact form problem
kiko5k's Avatar
Skilled Talker

Posts: 82
Trades: 0
Your hosting is the problem. Try to contact your hosting and ask them that you had an email form on your site. They will give you the .htaccess code so that you can receive the email. I think the code is something like global.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

kiko5k is offline
Reply With Quote
View Public Profile Visit kiko5k's homepage!
 
Reply     « Reply to PHP contact form problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.13278 seconds with 12 queries