logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 01-30-2012, 07:59 PM   #1
PHX22
 
Join Date: Jan 2012
Posts: 4
Default Blank PHP Form Emails

Salutations!

I have recently had the honor of being introduced to PHP and it's been a pain. I've read numerous other forums and threads referring to the Blank E-mail problem but still have not been able find a solution to mine.

Here is the PHP. I've disregarded the $results as it is working properly.

PHP Code:
<?php

$emailSubject 
'Information Request';
$mailto 'admin@mysite.com';



$nameField $_POST ['name'];
$companyField $_POST['company'];
$address_1Field $_POST ['address_1'];
$address_2Field $_POST ['address_2'];
$cityField $_POST['city'];
$stateField $_POST ['state'];
$countryField $_POST ['country'];
$phoneField $_POST['phone'];
$workphoneField $_POST ['workphone'];
$emailField $_POST ['email'];
$questionField $_POST ['question'];


$body = <<<EOD
<br><hr><br>
Name: 
$nameField <br>
Email: 
$emailField <br>
Company: 
$companyField <br>
Address_1: 
$address_1Field <br>
Address_2: 
$address_2Field <br>
City: 
$cityField <br>
State1: 
$stateField <br>
Country: 
$countryField <br>
Phone: 
$phoneField <br>
Work_Phone: 
$workphoneField <br>
Questions: 
$questionField <br>
EOD;

$headers "From: $email\r\n"
$headers .= "Content-type: text/html\r\n"
$success mail($mailto$emailSubject$body$headers);


        
$theResults = <<<EOD

I greatly appreciate all replies!
PHX22 is offline   Reply With Quote
Old 01-31-2012, 01:08 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,175
Default

odd because this works




<form action="" method="POST">




<label> email</label><input name="email" type="text">
<label> first tname</label><input name="name" type="text">
<label>last name</label><input name="company" type="text">
<label>telephone</label><input name="address_1" type="text">
<label>comments</label><textarea name="address_2" cols="8" rows="8"></textarea>
<input name="Send" class="button" type="submit" value="Submit">

</form>






<?php

$emailSubject = 'Information Request';
$mailto = 'admin@mysite.com';



$nameField = $_POST ['name'];
$companyField = $_POST['company'];
$address_1Field = $_POST['address_1'];
$address_2Field = $_POST['address_2'];
$cityField = $_POST['city'];
$stateField = $_POST['state'];
$countryField = $_POST['country'];
$phoneField = $_POST['phone'];
$workphoneField = $_POST['workphone'];
$emailField = $_POST['email'];
$questionField = $_POST['question'];


$body = <<<EOD
<br><hr><br>
Name: $nameField <br>
Email: $emailField <br>
Company: $companyField <br>
Address_1: $address_1Field <br>
Address_2: $address_2Field <br>
City: $cityField <br>
State1: $stateField <br>
Country: $countryField <br>
Phone: $phoneField <br>
Work_Phone: $workphoneField <br>
Questions: $questionField <br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";

//commented out for testing
//$success = mail($mailto, $emailSubject, $body, $headers);


echo $body;
?>
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 01-31-2012, 05:26 AM   #3
PHX22
 
Join Date: Jan 2012
Posts: 4
Default

Thank you for the reply...I don't quite understand what you mean with the form HTML...

HTML Code:
<form action="" method="POST">




<label> email</label><input name="email" type="text">
<label> first tname</label><input name="name" type="text">
<label>last name</label><input name="company" type="text">
<label>telephone</label><input name="address_1" type="text">
<label>comments</label><textarea name="address_2" cols="8" rows="8"></textarea>
<input name="Send" class="button" type="submit" value="Submit">

</form>
I tried removing
PHP Code:
 //Commented out for test //$success = mail($mailto, $emailSubject, $body, $headers); 
And still a blank form ends up in my spam box.
PHX22 is offline   Reply With Quote
Old 01-31-2012, 06:36 AM   #4
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,175
Default

to send mail it should be
Code:
<?php
remove comments so it should be
 $success = mail($mailto, $emailSubject, $body, $headers);

?>
do your form fields math names you show in you definitions?
post your form
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 01-31-2012, 04:18 PM   #5
PHX22
 
Join Date: Jan 2012
Posts: 4
Default

That's what I've got for the $success line, and here is the form. I believe they all match up, unless I've missed something bigger.

HTML Code:
<form id="form1" name="form1" method="POST" enctype="application/x-www-form-urlencoded" action="form_mailer.php">
        <p>
          <label>Please Enter Name Here</label>
          <input name="name" type="text" id="name" accesskey="1" tabindex="1" onblur="MM_validateForm('name','','R','email','','RisEmail');return document.MM_returnValue" size="20" />
        </p>
        <p>&nbsp;</p>
        <p>
          <label>Company </label>
          <input name="company" type="text" id="company" accesskey="2" tabindex="2" size="20" />
        </p>
        <p>&nbsp;</p>
        <p>
          <label>Address Line 1</label>
          <input name="address_1" type="text" id="address_1" accesskey="3" tabindex="3" size="20" />
        </p>
        <p>&nbsp;</p>
        <p>
          <label>Address Line 2</label>
          <input name="address2" type="text" id="address2" accesskey="4" tabindex="4" size="20" />
        </p>
        <p>&nbsp;</p>
        <p>
          <label>City</label>
          <input name="city" type="text" id="city" accesskey="5" tabindex="5" size="20" />
        </p>
        <p>&nbsp;</p>
        <p>
          <label>State or Province</label>
          <input name="state" type="text" id="state" accesskey="6" tabindex="6" size="5" />
        </p>
        <p>&nbsp;</p>
        <p>
          <label>Country</label>
          <input name="country" type="text" id="country" accesskey="7" tabindex="7" size="20" />
        </p>
        <p>&nbsp;</p>
        <p>
          <label>Zip Code</label>
          <input name="zip" type="text" id="zip" accesskey="8" tabindex="8" size="20" maxlength="9" />
        </p>
        <p>&nbsp;</p>
        <p>
          <label>Home Phone</label>
          <input name="phone" type="text" id="phone" accesskey="9" tabindex="9" value="" size="20" maxlength="15" />
        </p>
        <p>&nbsp;</p>
        <p>
          <label>Work Phone</label>
          <input name="workphone" type="text" id="workphone" accesskey="10" tabindex="10" size="20" maxlength="15" />
        </p>
        <p>&nbsp;</p>
        <p>
          <label>E-mail Address</label>
          <input name="email" type="text" id="email" accesskey="11" tabindex="11" size="20" />
        </p>
        <p>&nbsp;</p>
        <p>
          <label>Any comments or questions go here</label>
          <textarea name="questions" cols="45" rows="5" id="questions" accesskey="13" tabindex="13"></textarea>
        </p>
        <p>&nbsp;</p>
        <p>
          <input type="submit" name="submit form" id="submit" value="Submit Form" accesskey="14" tabindex="14" />
          <input type="reset" name="clear" id="clear" value="Clear Form" accesskey="15" tabindex="15" />
        </p>
      </form>
PHX22 is offline   Reply With Quote
Old 01-31-2012, 05:03 PM   #6
PHX22
 
Join Date: Jan 2012
Posts: 4
Default

@edbr, thank you for your replies and help, I scoured over the code and changed a couple things on the form page and it worked. Been facing this issue a while now, I'm pumped. Thanks again!

-Cheers
PHX22 is offline   Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 11:25 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com