Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Help PHP Email script

the mail() function

Moderators: macek, egami, gesf

Help PHP Email script

Postby dopeamin » Tue May 24, 2011 9:38 am

Hello there

Im new to PHP not a developer just a user

Anyway I created a PHP Script to process a web form from my website
http://curemypcny.com

Everything looks fine to me but when I receive a email I do get blank fields instead of information in it!!!

Would appreciate your help
<p><form action="contactformprocess.php" method="post">
<div align="right">
<table width="100%" border="0" cellpadding="6">
<tr>
<td width="52%"><div align="right">
<label for="mail">Email:</label>
</div></td>
<td width="48%"><div align="left">
<input name="mail" type="text" id="mail" size="35" maxlength="90" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="name">Name:</label>
</div></td>
<td><div align="left">
<input name="name" type="text" id="name" size="35" maxlength="100" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="phone">Phone:</label>
</div></td>
<td><div align="left">
<input name="phone" type="text" id="phone" size="35" maxlength="12" />
</div></td>
</tr>
<tr>
<td><div align="right">What is your device?</div></td>
<td><div align="left">
<p>
<label>
<input type="radio" name="device" value="Windows" id="Devices_0" />
PC - Windows</label>
<br />
<label>
<input type="radio" name="device" value="Mac" id="Devices_1" />
PC - Mac</label>
<br />
<label>
<input type="radio" name="device" value="Linux" id="Devices_2" />
PC - Linux</label>
<br />
<label>
<input type="radio" name="device" value="Smartphone - Iphone" id="Devices_3" />
Smartphone - Iphone</label>
<br />
<label>
<input type="radio" name="device" value="Smartphone - Android" id="Devices_4" />
Smartphone - Android</label>
<br />
<label>
<input type="radio" name="device" value="Smartphone - Blackberry" id="Devices_5" />
Smartphone - Blackberry</label>
<br />
<label>
<input type="radio" name="device" value="Ipad" id="Devices_6" />
Ipad</label>
<br />
</p>
</div></td>
</tr>
<tr>
<td height="27"><div align="right">
<label for="wrong">What's wrong?</label>
</div></td>
<td><div align="left">
<textarea name="wrong" id="wrong" cols="28" rows="5"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="how did you find about us">How did you find about Us?</label>
</div></td>
<td><div align="left">
<select name="how" id="how did you find about us">
<option>Choose...</option>
<option value="Buddy">Buddy</option>
<option value="Craigslist">Craigslist</option>
<option value="Newspaper">Newspaper</option>
<option value="Facebook">Facebook</option>
<option value="Google">Google</option>
<option value="Other">Other</option>
</select>
</div></td>
</tr>
<tr>
<td><div align="right">
<input type="reset" name="Reset" id="Reset" value="Reset Form" />
</div></td>
<td><div align="left">
<input name="submit" type="submit" id="submit" onclick="MM_validateForm('email','','RisEmail','name','','R','phone','','RisNum','whatswrong','','R');return document.MM_returnValue" value="Send email" />
</div></td>
</tr>

</table>
</div>


Above is the contact form!!!!!


<?php

/* Subject and email variables */


$emailSubject = 'you have an important email!';
$webMaster = 'ivokatovski@gmail.com';


/* Gathering Data Variables */

$mailField = $_POST['mail'];
$nameField = $_POST['name'];
$phoneField = $_POST['phone'];
$deviceField = $_POST['device'];
$wrongField = $_POST['wrong'];
$howField = $_POST['how'];


$body = <<<EOD
<br><hr><br>
Email : $mail <br>
Name : $name <br>
Phone number : $phone <br>
What is your device : $device <br>
What is wrong :$wrong <br>
How did you find about us :$how <br>
EOD;

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

/* Resoults rendered as HTML */

$theResults = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cure My PC</title>
<style type="text/css">
body {
background-image: url(images/Background.jpg);
background-repeat: repeat-x;
background-color: #C0D8F2;
}
</style>
<link href="css/layout.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="wrapper">
<div id="logo"><a href="index.html"><img src="images/logo.jpg" width="800" height="144" alt="logo" /></a></div>
<div id="navigationbar"><a href="index.html">Home</a> <a href="services.html">Services</a> <a href="rates.html">Rates</a> <a href="tips.html">Tips</a> <a href="conncet.html">Connect</a> </div>
<div id="bodyarea">
<div id="left">
<h3>Thank you for your interest your emal will be answered very soon!!</h3>
<p>&nbsp;</p>
</div>
<div id="right">
<div id="fb-root"></div>
</div>
<div id="footer">&copy;Cure My PC 2011</div>
</div>
</div>
</div>
</body>
</html>
EOD;
echo "$theResults";






?>



Above is the PHP script

Thank you in advance

Ivo
http://www.curemypcny.com
dopeamin
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue May 24, 2011 9:29 am
Location: New York

Re: Help PHP Email script

Postby bachans » Fri May 27, 2011 2:12 am

HI,

Nothing wrong in your code. You just bymistakely given different variable names.

Please change the code from
dopeamin wrote:$body = <<<EOD
<br><hr><br>
Email : $mail <br>
Name : $name <br>
Phone number : $phone <br>
What is your device : $device <br>
What is wrong :$wrong <br>
How did you find about us :$how <br>
EOD;

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


To
$body = <<<EOD
<br><hr><br>
Email : $mailField <br>
Name : $nameField <br>
Phone number : $phoneField <br>
What is your device : $deviceField <br>
What is wrong :$wrongField <br>
How did you find about us :$howField <br>
EOD;

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


Thanks
Bachan
bachans
New php-forum User
New php-forum User
 
Posts: 67
Joined: Thu May 19, 2011 6:01 am
Location: India


Return to PHP coding => Mail

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron