Jump to content

Php Email Form sending blank emails


URmusicandvideo

Recommended Posts

I have created a basic form php script from a video on youtube and I seem to have all working but when I get the email it shows the fields name, address etc... but the fields are blank.

 

Here is the code:

<?php
$emailsubject = 'Judgement Recovery Application' ;
$web = '[email protected]' ;



$casenumberField = $_POST['Casenu'];
$amountField = $_POST['Amountofjudgment'];
$collectedField = $_POST['Amountcollected'];
$stateField = $_POST['Statejudgment'];
$attnField = $_POST['Represented'];
$defaultField = $_POST['Awardeddefault'];
$dstateField = $_POST['dstate'];
$namejdField = $_POST['JD'];
$addjdField = $_POST['JDaddress'];
$cityjdField = $_POST['JDcity'];
$namejcField = $_POST['JCsName'];
$addjcField = $_POST['JCsAddress'];
$cityjcField = $_POST['JCsCity'];
$phoneField = $_POST['JCsPhone'];
$emailjcField = $_POST['JCsEmail'];
$descrpField = $_POST['Description'];
$judgeField = $_POST['Judgment'];

$body = <<<EOD
<br><hr><br>
Case Number: $casenumber <br>
Amount: $amount <br>
Collected: $collected <br>
State of Judgement: $state <br>
Attorney: $attn <br>
Award by Default: $default <br>
JD Reside Diffent State: $dstate <br>
Name: $namejd <br>
Address: $addjd <br>
City: $cityjd <br>
Phone: $phone <br>
Email: $emailjc <br>
Description: $descrp <br>
Judgement: $judge <br>
EOD;



$headers = "From:emailjcField\r\n";
$headers .= "Content-type: text/html\n\n";
$success = mail($web, $emailsubject, $body, $headers);



$theResults = <<<EOD
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Refresh" content="5; url=http://www.hydeandseik.com/home.html"> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thank you From  Hyde & Seik Investigations</title>

<style type="text/css">
<!--
body {
background-image: url(images/bg.jpg);
}
.style7 {
color: #FFFFFF;
font-weight: bold;
font-size: 18px;
}
.style13 {font-family: Broadway}
.style15 {font-size: xx-large}
-->
</style></head>

<body>

<div align="center"></div>
<h1 align="center" class="style7"><span class="style15"><span class="style13">Hyde & Seik</span>®</span><span class="style15"> Thanks you for your application and we will be in contact with you soon.</span></h1>
<p align="center"> </p>
<p align="center"> </p>
</body>
</html>
EOD;
echo "$theResults";



?> 

 

 

Thank you for all your help

Lee

Link to comment
https://forums.phpfreaks.com/topic/130735-php-email-form-sending-blank-emails/
Share on other sites

Hi Lee,

 

Give this a try:

 

<?php
$emailsubject = 'Judgement Recovery Application' ;
$web = '[email protected]' ;



$casenumberField = $_POST['Casenu'];
$amountField = $_POST['Amountofjudgment'];
$collectedField = $_POST['Amountcollected'];
$stateField = $_POST['Statejudgment'];
$attnField = $_POST['Represented'];
$defaultField = $_POST['Awardeddefault'];
$dstateField = $_POST['dstate'];
$namejdField = $_POST['JD'];
$addjdField = $_POST['JDaddress'];
$cityjdField = $_POST['JDcity'];
$namejcField = $_POST['JCsName'];
$addjcField = $_POST['JCsAddress'];
$cityjcField = $_POST['JCsCity'];
$phoneField = $_POST['JCsPhone'];
$emailjcField = $_POST['JCsEmail'];
$descrpField = $_POST['Description'];
$judgeField = $_POST['Judgment'];

$body = <<<EOD
<br><hr><br>
Case Number: $casenumberField <br>
Amount: $amountField <br>
Collected: $collectedField <br>
State of Judgement: $stateField<br>
Attorney: $attnField <br>
Award by Default: $defaultField <br>
JD Reside Diffent State: $dstateField<br>
Name: $namejdField <br>
Address: $addjdField <br>
City: $cityjdField <br>
Phone: $phoneField <br>
Email: $emailjcField <br>
Description: $descrpField <br>
Judgement: $judgeField <br>
EOD;



$headers = "From:emailjcField\r\n";
$headers .= "Content-type: text/html\n\n";
$success = mail($web, $emailsubject, $body, $headers);



$theResults = <<<EOD
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Refresh" content="5; url=http://www.hydeandseik.com/home.html"> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thank you From  Hyde & Seik Investigations</title>

<style type="text/css">
<!--
body {
background-image: url(images/bg.jpg);
}
.style7 {
color: #FFFFFF;
font-weight: bold;
font-size: 18px;
}
.style13 {font-family: Broadway}
.style15 {font-size: xx-large}
-->
</style></head>

<body>

<div align="center"></div>
<h1 align="center" class="style7"><span class="style15"><span class="style13">Hyde & Seik</span>®</span><span class="style15"> Thanks you for your application and we will be in contact with you soon.</span></h1>
<p align="center"> </p>
<p align="center"> </p>
</body>
</html>
EOD;
echo "$theResults";



?> 

You are not checking that anything has been posted, so how do you know if the post has a value?

My advice don't just follow videos, try and learn what the code is doing  and how its doing it ,rather than just knowing that it does do it.

 

Tizag.com

&

w3schools.com

 

Good sites to learn php.

 

This is improved a bit

<?php
   $emailsubject = 'Judgement Recovery Application' ;
   $web = '[email protected]' ;
   


   $casenumberField = $_POST['Casenu'];
   $amountField = $_POST['Amountofjudgment'];
   $collectedField = $_POST['Amountcollected'];
   $stateField = $_POST['Statejudgment'];
   $attnField = $_POST['Represented'];
   $defaultField = $_POST['Awardeddefault'];
   $dstateField = $_POST['dstate'];
   $namejdField = $_POST['JD'];
   $addjdField = $_POST['JDaddress'];
   $cityjdField = $_POST['JDcity'];
   $namejcField = $_POST['JCsName'];
   $addjcField = $_POST['JCsAddress'];
   $cityjcField = $_POST['JCsCity'];
   $phoneField = $_POST['JCsPhone'];
   $emailjcField = $_POST['JCsEmail'];
   $descrpField = $_POST['Description'];
   $judgeField = $_POST['Judgment'];
   
   $body ="
<br><hr><br>
Case Number: ".$casenumberField." <br>
Amount: ".$amountField." <br>
Collected: ".$collectedField." <br>
State of Judgement: ".$stateField."<br>
Attorney: ".$attnField." <br>
Award by Default: ".$defaultField." <br>
JD Reside Diffent State: ".$dstateField."<br>
Name: ".$namejdField." <br>
Address: ".$addjdField." <br>
City: ".$cityjdField." <br>
Phone: ".$phoneField." <br>
Email: ".$emailjcField." <br>
Description: ".$descrpField." <br>
Judgement: ".$judgeField." <br>
";



   $headers = "From:emailjcField\r\n";
   $headers .= "Content-type: text/html\n\n";
   $success = mail($web, $emailsubject, $body, $headers);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Refresh" content="5; url=http://www.hydeandseik.com/home.html"> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thank you From  Hyde & Seik Investigations</title>

<style type="text/css">
<!--
body {
   background-image: url(images/bg.jpg);
}
.style7 {
   color: #FFFFFF;
   font-weight: bold;
   font-size: 18px;
}
.style13 {font-family: Broadway}
.style15 {font-size: xx-large}
-->
</style></head>

<body>

<div align="center"></div>
<h1 align="center" class="style7"><span class="style15"><span class="style13">Hyde & Seik</span>®</span><span class="style15"> Thanks you for your application and we will be in contact with you soon.</span></h1>
<p align="center"> </p>
<p align="center"> </p>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.