Reply LinkBack Thread Tools Search this Thread
Old 05-03-2010, 14:50   #1 (permalink)
slippers
Registered User
 
Join Date: Nov 2009
Posts: 21
contact form sending blank email?

Can someone please tell me why my contact form is sending blank emails? Iv posted my php for anyone that has time to help. due having not hitting the magic 15 posts yet i taken out my url and email. thanks

PHP Code:
<?php

/* Subject and email variables */ 

$emailSubject 'contactformprocess';
$webMaster 'MY EMAIL';


/* Gathering data variables */ 

$emailfield $_POST['email'];
$namefield $_POST['name'];
$phonefield $_POST['phone'];
$messagefield $_POST['message'];

$body = <<<EOD
<br><hr><br>
Name: $namefield <br>
Email: $emailfield <br>
Phone Number: $phonenumberfield <br>
Your Message: $yourmessagefield <br>
EOD;

$headers "From: $emailfield\r\n";
$headers "Content-type: text/html\r\n";
$success mail($webMaster$emailSubject$body$headers); 


/* Results rendered as HTML */

$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="5;URL=http://MY WEBSITE">
<style type="text/css">
<!--
body {
background-color: #9BCB3B;
font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #fff;
text-decoration: none;
padding-top: 200px;
margin-left: 15%;
margin-right: 15%;
text align: center
width: 800px;
}

-->
</style>
</head>
<div align="center">Your email will be answered as soon as possible!
You will be returned to RJF Design in a few seconds !</div>
</div>
</body>
</html>
EOD;
echo 
"$theResults";
?>
  Reply With Quote
Old 05-03-2010, 15:14   #2 (permalink)
.sleep
Senior Member
 
.sleep's Avatar
 
Join Date: Mar 2007
Location: california
Posts: 572
Send a message via AIM to .sleep
Is there no body to the email at all or just the fields are showing up empty?

Also, your $headers var is overwriting the From field. Need to have .=
__________________
  Reply With Quote
Old 05-03-2010, 15:17   #3 (permalink)
slippers
Registered User
 
Join Date: Nov 2009
Posts: 21
Yeah i get a email saying

name:
email:
phone number:
your message:

but obviously when testing it i have been filling the fields in yet im still just getting that in my email.
  Reply With Quote
Old 05-03-2010, 15:23   #4 (permalink)
jon
Registered User
 
jon's Avatar
 
Join Date: Feb 2003
Location: York, UK
Posts: 21
I don't use <<<EOD very often, but maybe you can't stick variables in them.

Try:

Code:
$body = 'Form post '."\n"; $body.= 'Name: '.$namefield."\n"; $body.= 'Email: '.$emailfield."\n"; $body.= 'Phone Number: '.$phonenumberfield."\n"; $body.= 'Your Message: '.$yourmessagefield."\n";
  Reply With Quote
Old 05-03-2010, 15:46   #5 (permalink)
slippers
Registered User
 
Join Date: Nov 2009
Posts: 21
Quote:
Originally Posted by jon
I don't use <<<EOD very often, but maybe you can't stick variables in them.

Try:

Code:
$body = 'Form post '."\n"; $body.= 'Name: '.$namefield."\n"; $body.= 'Email: '.$emailfield."\n"; $body.= 'Phone Number: '.$phonenumberfield."\n"; $body.= 'Your Message: '.$yourmessagefield."\n";

Afraid that dosnt work either.

could it hav anything to do with this?

HTML Code:
<div id="blog"> <form action="contactformprocess.php" methods="post" name="form" id="form1"> <p>Name<br /> <input name="name" type="text" size="25" maxlength="40" /> Email<br /> <input name="email" type="text" size="25" maxlength="40" /> Phone Number<br /> <input name="Phone Number" type="text" size="25" maxlength="40" /> Your Message<br /> <textarea name="comments" cols="22" rows="5"></textarea> <br /> <input type="submit" name="submit" id="submit" value="send email" /> <input type="reset" name="reset" id="reset" value="clear" /> </form></div>
  Reply With Quote
Old 05-03-2010, 17:40   #6 (permalink)
fasterthanlight
FUNKTION GALLERY
 
fasterthanlight's Avatar
 
Join Date: Jun 2008
Location: Toronto
Posts: 2,393
in your HTML,

your <input name="xxxxx"> needs to match what you are looking for in the POST.

Code:
<div id="blog"> <form action="contactformprocess.php" methods="post" name="form" id="form1"> <p>Name<br /> <input name="name" type="text" size="25" maxlength="40" /> Email<br /> <input name="email" type="text" size="25" maxlength="40" /> Phone Number<br /> <input name="Phone Number" type="text" size="25" maxlength="40" /> Your Message<br /> <textarea name="comments" cols="22" rows="5"></textarea> <br /> <input type="submit" name="submit" id="submit" value="send email" /> <input type="reset" name="reset" id="reset" value="clear" /> </form></div>

(note: your <input name="Phone Number"> should be rewritten without spaces)

Everything I've bolded from the above code needs to match whats here (bolded):

Code:
/* Gathering data variables */ $emailfield = $_POST['email']; $namefield = $_POST['name']; $phonefield = $_POST['phone']; $messagefield = $_POST['message'];

which, most don't.

also a couple lines further you've renamed your variables again.

Code:
Phone Number: $phonenumberfield <br> Your Message: $yourmessagefield <br>

$phonenumberfield should actually be $phonefield
and
$yourmessagefield should be $messagefield
__________________
  Reply With Quote
Old 05-03-2010, 17:42   #7 (permalink)
Zod
Ruler of Planet Houston
 
Zod's Avatar
 
Join Date: Feb 2010
Posts: 139
the names on your form don't match your $_POSTs (phone number, comments)and having a 2 word name will break the form anyway - change name="phone number" to name="phone" and name="comments" to name="message" then try again

Doh! Beaten to it
  Reply With Quote
Old 05-03-2010, 19:34   #8 (permalink)
slippers
Registered User
 
Join Date: Nov 2009
Posts: 21
I think iv tryed what you guys suggested but im still recieving a email with no info.

name:
email:
phone number:
your message:

HTML Code:
<div id="blog"> <form action="contactformprocess.php" methods="post" name="form" id="form1"> <p>Name<br /> <input name="name" type="text" size="25" maxlength="40" /> Email<br /> <input name="email" type="text" size="25" maxlength="40" /> Phone Number<br /> <input name="phone" type="text" size="25" maxlength="40" /> Your Message<br /> <textarea name="message" cols="22" rows="5"></textarea> <br /> <input type="submit" name="submit" id="submit" value="send email" /> <input type="reset" name="reset" id="reset" value="clear" /> </form></div>

PHP Code:
<?php

/* Subject and email variables */ 

$emailSubject 'contactformprocess';
$webMaster 'slippersfisher@hotmail.com';


/* Gathering data variables */ 

$namefield $_POST['name'];
$emailfield $_POST['email'];
$phonefield $_POST['phone'];
$messagefield $_POST['message'];

$body = <<<EOD
<br><hr><br>
Name: $namefield <br>
Email: $emailfield <br>
Phone Number: $phonefield <br>
Your Message: $messagefield <br>
EOD;

$headers "From: $emailfield\r\n";
$headers "Content-type: text/html\r\n";
$success mail($webMaster$emailSubject$body$headers); 


/* Results rendered as HTML */

$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="5;URL=http://www.rjf-design.co.uk">
<style type="text/css">
<!--
body {
background-color: #9BCB3B;
font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #fff;
text-decoration: none;
padding-top: 200px;
margin-left: 15%;
margin-right: 15%;
text align: center
width: 800px;
}

-->
</style>
</head>
<div align="center">Your email will be answered as soon as possible!
You will be returned to RJF Design in a few seconds !</div>
</div>
</body>
</html>
EOD;
echo 
"$theResults";
?>
  Reply With Quote
Old 05-03-2010, 20:29   #9 (permalink)
.sleep
Senior Member
 
.sleep's Avatar
 
Join Date: Mar 2007
Location: california
Posts: 572
Send a message via AIM to .sleep
I don't think methods="post" is valid. It should be method="post" should it not?

Also, you still have not fixed the $headers variable.
__________________
  Reply With Quote
Old 06-03-2010, 06:28   #10 (permalink)
slippers
Registered User
 
Join Date: Nov 2009
Posts: 21
By changing methods= to method= has resulted in it working now. thanks for all your help everyone.
  Reply With Quote
Old 06-03-2010, 06:42   #11 (permalink)
Zod
Ruler of Planet Houston
 
Zod's Avatar
 
Join Date: Feb 2010
Posts: 139
Well spotted!
  Reply With Quote
Reply



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

Advanced Search


Contact Us - Web Design Forums - Archive
Web Hosting by Heart Internet, vBulletin © 2000-2009 Jelsoft Enterprises Limited.
Search Engine Optimization by vBSEO 3.0.0 RC8
Web Hosting by Heart Internet