Web Hosting Deals Holiday Logo Design Website Header Templates Register domain Search Engine Optimisation Web Hosting
Go Back   Talk Mania Forum > Tutorials > How to ....

How to .... Learn how to do anything and get what you need to do it - from experts and people like you.

 Image
Buy Sell Downloads

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-15-2007, 11:12 PM
Junior Member
 
Join Date: Jun 2007
Posts: 10
monkeymafia is on a distinguished road
contact form help please

Hi i have a contact form on my website and when the submit button is pressed, i do actually recieve an email but its blank. please help me, i have no idea how to fix it.

Heres the code for my form in html
Code:
<form method ="post" action="send.php">
 
      
	   
      <p class="areatext">Your name:<br /> 
        <input name="name" size="25"> 
      </p> <br>
      <p class="areatext">E-mail address:<br /> 
        <input name="email" size="25"> 
      </p> <br>
      <p class="areatext">Your message:<br> 
        <textarea name="message" rows="4" cols="50"></textarea> 
      </p> <br>
      <p class="areatext"> 
        <input type="submit" value="submit"> 
        <input type="reset" value="Clear"> 
      </p> 
    </form>
and this is my code for my "send.php" document:

Code:
<?php
 
// Details
$message="$message"; 

// Mail of sender
$mail_from="$email"; 
// From 
$header="from: $name <$mail_from>"; 

// Enter your email address
$to ='my email address'; 

$send_contact=mail($to,$message,$header);

// Check, if message sent to your email 
// display message "Thank you we have recieved your email, we will get back to you as soon as possible"
if($send_contact){
echo "We've recived your email";
}
else {
echo "ERROR";
}
?>
I have spent a long time trying to get this to work, but php is not my strong point. please hellllp

Reply With Quote
  #2 (permalink)  
Old 06-15-2007, 11:23 PM
Senior Member
 
Join Date: May 2007
Posts: 181
Blog Entries: 1
skyfe is on a distinguished road
Quote:
Originally Posted by monkeymafia View Post
Hi i have a contact form on my website and when the submit button is pressed, i do actually recieve an email but its blank. please help me, i have no idea how to fix it.

Heres the code for my form in html
Code:
<form method ="post" action="send.php">
 
      
	   
      <p class="areatext">Your name:<br /> 
        <input name="name" size="25"> 
      </p> <br>
      <p class="areatext">E-mail address:<br /> 
        <input name="email" size="25"> 
      </p> <br>
      <p class="areatext">Your message:<br> 
        <textarea name="message" rows="4" cols="50"></textarea> 
      </p> <br>
      <p class="areatext"> 
        <input type="submit" value="submit"> 
        <input type="reset" value="Clear"> 
      </p> 
    </form>
and this is my code for my "send.php" document:

Code:
<?php
 
// Details
$message="$message"; 

// Mail of sender
$mail_from="$email"; 
// From 
$header="from: $name <$mail_from>"; 

// Enter your email address
$to ='my email address'; 

$send_contact=mail($to,$message,$header);

// Check, if message sent to your email 
// display message "Thank you we have recieved your email, we will get back to you as soon as possible"
if($send_contact){
echo "We've recived your email";
}
else {
echo "ERROR";
}
?>
I have spent a long time trying to get this to work, but php is not my strong point. please hellllp
of course it's blank... check this:
$message="$message";
lol? :P 1. It's equal to its self.. and that's nothing 2.it's set into a string(the var). use this instead for those files:

form
Code:
<form method="POST" action="send.php">
 
      
	   
      <p class="areatext">Your name:<br /> 
        <input name="name" size="25"> 
      </p> <br>
      <p class="areatext">E-mail address:<br /> 
        <input name="email" size="25"> 
      </p> <br>
      <p class="areatext">Your message:<br> 
        <textarea name="message" rows="4" cols="50"></textarea> 
      </p> <br>
      <p class="areatext"> 
        <input type="submit" value="submit"> 
        <input type="reset" value="Clear"> 
      </p> 
    </form>
send.php


Code:
<?php
 
// Details
$message = $_POST['message']; 

// Mail of sender
$mail_from = $_POST['email']; 
// From 
$header="from: ".$_POST['name']."<".$mail_from.">"; 

// Enter your email address
$to ='my email address'; 

$send_contact = mail($to,$message,$header);

// Check, if message sent to your email 
// display message "Thank you we have recieved your email, we will get back to you as soon as possible"
if($send_contact){
echo "We've recived your email";
}
else {
echo "ERROR";
}
?>
try this Not tested either But this should work! Good luck!

EDIT: You can also make 1 file of those:

Code:
<?php
if(isset($_POST['submit'])) { //if the user tried to sent the mail(pressed the submit button)

// Details
$message = $_POST['message']; 

// Mail of sender
$mail_from = $_POST['email']; 
// From 
$header="from: ".$_POST['name']."<".$mail_from.">"; 

// Enter your email address
$to ='my email address'; 

$send_contact = mail($to,$message,$header);

// Check, if message sent to your email 
// display message "Thank you we have recieved your email, we will get back to you as soon as possible"
if($send_contact){
echo "We've recived your email";
}
else {
echo "ERROR";
}

}else{
?>
<form method="POST" action="send.php">
 
      
	   
      <p class="areatext">Your name:<br /> 
        <input name="name" size="25"> 
      </p> <br>
      <p class="areatext">E-mail address:<br /> 
        <input name="email" size="25"> 
      </p> <br>
      <p class="areatext">Your message:<br> 
        <textarea name="message" rows="4" cols="50"></textarea> 
      </p> <br>
      <p class="areatext"> 
        <input type="submit" value="submit" name="submit"> 
        <input type="reset" value="Clear"> 
      </p> 
    </form>
<?php } ?>

Last edited by skyfe; 06-15-2007 at 11:26 PM.
Reply With Quote
  #3 (permalink)  
Old 06-15-2007, 11:40 PM
Junior Member
 
Join Date: Jun 2007
Posts: 10
monkeymafia is on a distinguished road
i suspected it had something to do with that. thanks for the quick reply! and yes it works! but when i check the message submitted in my email, the actual message is in the subject of the email. what now
Reply With Quote
  #4 (permalink)  
Old 06-16-2007, 12:08 AM
Senior Member
 
Join Date: May 2007
Posts: 181
Blog Entries: 1
skyfe is on a distinguished road
Ah, I know what's wrong. The mail function works like:
mail(to,subject,message,headers);
you did:
$send_contact = mail($to,$message,$header);
so change it to:
Code:
$send_contact = mail($to,$subject,$message,$header);
where $subject contains the subject.
Reply With Quote
  #5 (permalink)  
Old 06-16-2007, 12:32 AM
Junior Member
 
Join Date: Jun 2007
Posts: 10
monkeymafia is on a distinguished road
perfect! thanks for your help!
Reply With Quote
  #6 (permalink)  
Old 06-16-2007, 08:17 AM
Senior Member
 
Join Date: May 2007
Posts: 181
Blog Entries: 1
skyfe is on a distinguished road
no problem I'm glad I could help you! Good luck with your contact form!

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +2. The time now is 10:13 AM.



Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC8
Forums Copyright © Talk-Mania.com