PDA

View Full Version : PHP frustration.


Villavicencio
09-02-2011, 02:21 PM
I always seem soooo close to getting my contact page to work. I am getting the email BUT the name and company fields are not working. Can someone please tell me where I am going wrong?!

The contact form:
<table cellpadding="0" cellspacing="0" border="0" class="maintext">

<form action="contactformprocess.php" method="post" id="contactform">
<tr>
<td width="107" align="right"><label for= "name">Name&nbsp;</label></td><td width="356"><input name="name" id="name" type="text" style="width:310px; height:20px;" /></td></tr>
<tr><td height="5"></td></tr
><tr>
<td align="right"><label for="company">Company&nbsp;</label></td><td><input name="company" id="company" type="text" style="width:310px; height:20px;" /></td></tr
>
<tr><td height="5"></td></tr>
<tr>
<td align="right"><label for= "email">Email Address&nbsp;</label></td><td><input name="email" id="email" type="text" style="width:310px; height:20px;" /></td></tr
>
<tr><td height="5"></td></tr>
<tr>
<td align="right"><label for= "subject">Subject &nbsp;</label></td><td><input name="subject" id="subject" type="text" style="width:310px; height:20px;" /></td></tr
>
<tr><td height="5"></td></tr><tr>
<td align="right">Message &nbsp;</td><td><textarea name="message" style="width:310px; height:100px;"></textarea>
</td></tr
>
<tr><td height="5"></td></tr>
<tr>
<td></td>
<td><p>
<input type="submit" name="submit" value="submit">
</p></td>
</tr>
</tr></form></table>


My php code
<?php

/* Email Variables */
$emailSubject = 'amddetailing.com';
$webMaster = 'contactus@amddetailing.com';
/* Data Variables */

$name = $_POST['name'];
$company = $_POST['company'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];

$body = <<<EOD
<br><hr><br>
Name: $name1 <br>
Company: $company1 <br>
Email: $email <br>
Subject: $subject <br>
Message: $message <br>

EOD;

$headers = "From: $email\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="2;URL=http://www.amddetailing.com/">

<style type="text/css">

<!--

body {

background-color: #EDF4FF;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 20px;

font-style: normal;

line-height: normal;

font-weight: normal;

color: #000033;

text-decoration: none;

padding-top: 200px;

margin-left: 150px;

width: 800px;

}
-->
</style>
</head>
<div align="center">Your email will be answered soon as possible!
<br/>
You will return to Aircraft Mobile Detailing in a few seconds !</div>
</div>
</body>
</html>

EOD;

echo "$theResults";

?>

edbr
09-02-2011, 02:47 PM
in $body it should be$name and $company drop the 1 and it should be fine

Villavicencio
09-02-2011, 04:59 PM
That code was driving me crazy. I knew there was something small I was missing. Now that I have figured it out. I am having trouble with another form.

I am not getting the information from my check boxes in my quote area. Thank you for taking a look at this. This is my first time doing this.

<form action="quoteformprocess.php" method="post" name="Quote">
<div class="div2">
Please select the service(s) you require for your Airplane and submit your request for quotation / service.


<table id="CheckBoxServices" class="span2" border="0" style="width:825px;">

<tr>
<td width="401"><input id="CheckBoxServices_1" type="checkbox" name="CheckBoxServices$1" /><label for="CheckBoxServices_1"> Trip Ready Exterior Clean</label></td>
<td width="414"><input id="CheckBoxServices_2" type="checkbox" name="CheckBoxServices$2" /><label for="CheckBoxServices_2"> Trip Ready Interior Clean</label></td>

</tr><tr><td>&nbsp;</td></tr>
<tr>

<td><input id="CheckBoxServices3" type="checkbox" name="CheckBoxServices3" /><label for="CheckBoxServices3"> Wet Wash Aircraft</label></td>
<td><input id="CheckBoxServices4" type="checkbox" name="CheckBoxServices4" /><label for="CheckBoxServices4">Window Cleaning</label></td>

</tr><tr>
<td><input id="CheckBoxServices5" type="checkbox" name="CheckBoxServices5" /><label for="CheckBoxServices5">Dry Wash Aircraft</label></td>
<td><input id="CheckBoxServices6" type="checkbox" name="CheckBoxServices6" /><label for="CheckBoxServices6">Carpet Extraction</label></td>

</tr><tr>

<td><input id="CheckBoxServices7" type="checkbox" name="$CheckBoxServices7" /><label for="CheckBoxServices7">Hand Wax Exterior Paint</label></td>
<td><input id="CheckBoxServices8" type="checkbox" name="$CheckBoxServices8" /><label for="CheckBoxServices8">Upholstery Dry Cleaning</label></td>

</tr><tr>

<td><input id="CheckBoxServices9" type="checkbox" name="CheckBoxServices9" /><label for="CheckBoxServices9">Machine Buff Exterior Paint</label></td>
<td><input id="CheckBoxServices10" type="checkbox" name="CheckBoxServices10" /><label for="CheckBoxServices10">Stain Removal</label></td>

</tr><tr>

<td><input id="CheckBoxServices11" type="checkbox" name="CheckBoxServices11" /><label for="CheckBoxServices11">BrightWork / Polish Leading Edges</label></td>
<td><input id="CheckBoxServices12" type="checkbox" name="CheckBoxServices12" /><label for="CheckBoxServices12">Fabric & Leather Cleaning</label></td>

</tr><tr>

<td><input id="CheckBoxServices13" type="checkbox" name="CheckBoxServices13" /><label for="CheckBoxServices13">De-Ice Boots Refurbish</label></td>
<td><input id="CheckBoxServices14" type="checkbox" name="CheckBoxServices14" /><label for="CheckBoxServices14">Wood & Trim Polishing</label></td>

</tr><tr><td><input id="CheckBoxServices15" type="checkbox" name="CheckBoxServices15" /><label for="CheckBoxServices15">Clean Gear Wells</label></td>
<td><input id="CheckBoxServices16" type="checkbox" name="CheckBoxServices16" /><label for="CheckBoxServices16"> Lavatory Sanitation</label></td></tr>
<tr>
<td>&nbsp;</td><td>&nbsp;</td>
</tr><tr>
<td valign="top">
<input id="CheckBoxServices_17" type="checkbox" name="CheckBoxServices$17" /><label for="CheckBoxServices_17">PERMAGARD Coating &amp; Sealant</label></td>
<td><label for="other">Other (Specify) <br /></label>
<textarea name="other" rows="2" id="other"></textarea></td>
</tr></table></div>
<div class="div2">Customer Information
<table>
<tr>
<td height="61">
<div class="div3">

<div class="nameArea"><label for="name">Name:</label></div>
<div class="InputArea"><input name="name" type="text" class="text" id="name" />
<span class="error">&nbsp;*</span></div>
<span id="RequiredFieldValidator1" style="color:White;display:none;">*</span>

</div></td><td>
<div class="div3">

<div class="nameArea"><label for="company">Company Name:</label></div>

<div class="InputArea"><input name="company" type="text" id="company" class="text" /></div>

</div>

</td>
<tr> <td><div class="div3">

<div class="nameArea"><label for="phone">Phone:</label></div>
<div class="InputArea"><input name="phone" type="text" id="phone" class="text" /></div>
</div>

</td><td>
<div class="div3">
<div class="nameArea"><label for="fax">Fax:</label></div>
<div class="InputArea"><input name="fax" type="text" id="fax" class="text" /></div>

</div>
</td></tr>

<tr><td>
<div class="div3">

<div class="nameArea"><label for="email">E-mail:</label></div>

<div class="InputArea"><input name="email" type="text" id="email" class="text" />
<span class="error">&nbsp;*</span></div>
<span id="ValidEmail" style="color:White;display:none;">*</span>

<span id="EmailRegexValidator" style="color:White;display:none;">*</span>

</div>
</td>
<td>
<div class="div3">
<div class="nameArea"><label for="address">Address:</label></div>
<div class="InputArea"><textarea name="address" rows="3" cols="5" id="address" class="text"></textarea></div>

</div>
</td></tr>
<tr><td>
<div class="div3">

<div class="nameArea"><label for="aircrafttype">Aircraft Type:</label></div>
<div class="InputArea"><input name="aircrafttype" type="text" class="text" id="aircrafttype" size="90" /></div>
</div>
</td>
<td>
<div class="div3">
<div class="nameArea"><label for="aircraftmodel">Aircraft Model:</label></div>
<div class="InputArea"><input name="aircraftmodel" type="text" id="aircraftmodel" class="text" /></div>

</div>
</td></tr>
<tr><td>
<div class="div3">
<div class="nameArea"><label for="aircraftlocation">Aircraft Location:</label></div>
<div class="InputArea"><input name="aircraftlocation" type="text" class="text" id="aircraftlocation" size="90" /></div>
</div>
</td>
<td>
</td></tr>
</table>


</div>
<div class="bodyPan1" >

<div class="div5">

Fields marked with<span class="required">&nbsp;*&nbsp;</span>are required<br />


<input type="submit" name="submit" value="submit">

</div></div>
<!-- stop editing from here --><br clear="all" />
<!-- tagline below this mark --><!-- end .content -->
</form>

<?php

/* Email Variables */

$emailSubject = 'quoteformprocess';

$webMaster = 'contactus@amdetailing.com';


/* Data Variables */

$name = $_POST['name'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$email = $_POST['email'];
$address = $_POST['address'];
$aircrafttype = $_POST['aircrafttype'];
$aircraftmodel = $_POST['aircraftmodel'];
$aircraftlocation = $_POST['aircraftlocation'];

$CheckBoxServices1 = $_POST['Trip Ready Exterior Clean'];
$CheckBoxServices2 = $_POST['Trip Ready Interior Clean'];
$CheckBoxServices3 = $_POST['Wet Wash Aircraft'];
$CheckBoxServices4 = $_POST['Window Cleaning'];
$CheckBoxServices5 = $_POST['Dry Wash Aircraft'];
$CheckBoxServices6 = $_POST['Carpet Extraction'];
$CheckBoxServices7 = $_POST['Hand Wax Exterior Paint'];
$CheckBoxServices8 = $_POST['Upholstery Dry Cleaning'];
$CheckBoxServices9 = $_POST['Machine Buff Exterior Paint'];
$CheckBoxServices10 = $_POST['Stain Removal'];
$CheckBoxServices11 = $_POST['BrightWork / Polish Leading Edges'];
$CheckBoxServices12 = $_POST['Fabric & Leather Cleaning'];
$CheckBoxServices13 = $_POST['De-Ice Boots Refurbish'];
$CheckBoxServices14 = $_POST['Wood & Trim Polishing'];
$CheckBoxServices15 = $_POST['Clean Gear Wells'];
$CheckBoxServices16 = $_POST[' Lavatory Sanitation'];
$CheckBoxServices17 = $_POST['PERMAGARD Coating Sealant'];
$other = $_POST['other'];


$body = <<<EOD

<br><hr><br>
Contact Information <br>
Name: $name <br>
Company: $company <br>
Phone: $phone <br>
Fax: $fax <br>
Email: $email <br>
Address: $address <br>
Aircraft type: $aircrafttype <br>
Aircraft Model: $aircraftmodel <br>
Aircraft Location : $aircraftlocation <br><br>
Services Requested <br>
Trip Ready Exterior Clean: $CheckBoxServices1 <br>
Trip Ready Interior Clean: $CheckBoxServices2 <br>
Wet Wash: $CheckBoxServices3 <br>
Window Cleaning: $CheckBoxServices4 <br>
Dry Wash: $CheckBoxServices5 <br>
Carpet Extraction: $CheckBoxServices6 <br>
Hand Wax Exterior Paint: $CheckBoxServices7 <br>
Upholstery Dry Cleaning: $CheckBoxServices8 <br>
Machine Buff Exterior Paint: $CheckBoxServices9 <br>
Stain Removal: $CheckBoxServices10 <br>
Brightwork: $CheckBoxServices11 <br>
Fabric Leather Cleaning: $CheckBoxServices12 <br>
De Ice Boots: $CheckBoxServices13
Wood Trim Polishing: $CheckBoxServices14 <br>
Clean Gear Wells: $CheckBoxServices15 <br>
Lavatory Sanitation: $CheckBoxServices16 <br>
PERMAGARD Coating Sealant: $CheckBoxServices17 <br>
Other: $other <br>

EOD;

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

/* Results rendered as HTML */
EOD;

$headers = "From: $email\r\n";

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

$success = mail($webMaster, $emailSubject, $body,

$headers);


$theResults = <<<EOD

<html>

<head>

<title>sent message</title>

<meta http-equiv="refresh" content="2;URL=http://www.amdetailing.com/">

<style type="text/css">

<!--

body {

background-color: #EDF4FF;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 20px;

font-style: normal;

line-height: normal;

font-weight: normal;

color: #000033;

text-decoration: none;

padding-top: 200px;

margin-left: 150px;

width: 800px;

}
-->
</style>
</head>
<div align="center">Your email will be answered soon as possible!
<br/>
You will return to Aircraft Mobile Detailing in a few seconds !</div>
</div>
</body>
</html>

EOD;

echo "$theResults";

?>

edbr
09-03-2011, 01:10 AM
your post values are wrong , use the names hers the list of your post values that are passed

on stipulating that the check box has been selected

CheckBoxServices$1 : on
CheckBoxServices$2 : on
CheckBoxServices3 : on
CheckBoxServices4 : on
CheckBoxServices5 : on
CheckBoxServices6 : on
$CheckBoxServices7 : on
$CheckBoxServices8 : on
CheckBoxServices9 : on
CheckBoxServices10 : on
CheckBoxServices11 : on
CheckBoxServices12 : on
CheckBoxServices13 : on
CheckBoxServices14 : on
CheckBoxServices15 : on
CheckBoxServices16 : on
CheckBoxServices$17 : on
other : other
name : name
company : Company Name:
phone : phone
fax : Fax:
email : email
address : Address:
aircrafttype : Aircraft Type:
aircraftmodel : Aircraft Model:
aircraftlocation : Aircraft Location:
submit : submit

Villavicencio
09-03-2011, 03:04 PM
That worked perfectly. I am so glad I found this site. You have been a lifesaver :mrgreen:

gigiloumill
09-24-2011, 12:32 PM
He's a genius...

edbr
09-26-2011, 01:15 AM
haha my mother speaks well of me sometimes

Villavicencio
02-16-2012, 08:44 PM
Hey,

thank you so much for helping me with this. It has been working perfectly, a little too perfectly in that I have been getting blank submits. The php is working because I have tested it.

Is there a way I can make name and email fields required in this script which will force the person to submit contact information?

edbr
02-17-2012, 12:17 AM
yes cheap and cheerful way would be to use die() although some php purists would get funky about it being for debugging try this at the top of your script

if($_POST['name'] || $_POST['email'] ==" "){
die("please go back and fill in the required fiels email and name:):




test and let me know as i havent :)

Villavicencio
02-17-2012, 03:22 AM
I tried and it did not work. All I got was a blank page.

edbr
02-17-2012, 06:17 AM
if($_POST['name'] || $_POST['email'] ==" "){
die("please go back and fill in the required fields email and name"):
try that

Villavicencio
02-17-2012, 01:33 PM
I tried this and was getting the same problem of a blank page

I received this error in my error log 17-Feb-2012 07:23:26] PHP Parse error: syntax error, unexpected ':' in /.../quoteformprocess2.php on line 3"

So I changed : to ; and received this error [17-Feb-2012 07:28:45] PHP Parse error: syntax error, unexpected $end in /.../quoteformprocess2.php on line 130

edbr
02-18-2012, 12:36 AM
i never learn it seems, i should not post when im pushed for time!
time to quit maybe.

gere i added a form for test ing purposes but it is tested




<form action="" method="post">

<input name="name" type="text">
<input name="email" type="text">

<input name="" type="submit" value="Submit">
</form><?php
if(!$_POST['name'] || !$_POST['email']){
die('please go back and fill in the required fields email and name');}
/* Email Variables */

$emailSubject = 'quoteformprocess';

$webMaster = 'contactus@amdetailing.com';


/* Data Variables */

$name = $_POST['name'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$email = $_POST['email'];
$address = $_POST['address'];
$aircrafttype = $_POST['aircrafttype'];
$aircraftmodel = $_POST['aircraftmodel'];
$aircraftlocation = $_POST['aircraftlocation'];

$CheckBoxServices1 = $_POST['Trip Ready Exterior Clean'];
$CheckBoxServices2 = $_POST['Trip Ready Interior Clean'];
$CheckBoxServices3 = $_POST['Wet Wash Aircraft'];
$CheckBoxServices4 = $_POST['Window Cleaning'];
$CheckBoxServices5 = $_POST['Dry Wash Aircraft'];
$CheckBoxServices6 = $_POST['Carpet Extraction'];
$CheckBoxServices7 = $_POST['Hand Wax Exterior Paint'];
$CheckBoxServices8 = $_POST['Upholstery Dry Cleaning'];
$CheckBoxServices9 = $_POST['Machine Buff Exterior Paint'];
$CheckBoxServices10 = $_POST['Stain Removal'];
$CheckBoxServices11 = $_POST['BrightWork / Polish Leading Edges'];
$CheckBoxServices12 = $_POST['Fabric & Leather Cleaning'];
$CheckBoxServices13 = $_POST['De-Ice Boots Refurbish'];
$CheckBoxServices14 = $_POST['Wood & Trim Polishing'];
$CheckBoxServices15 = $_POST['Clean Gear Wells'];
$CheckBoxServices16 = $_POST[' Lavatory Sanitation'];
$CheckBoxServices17 = $_POST['PERMAGARD Coating Sealant'];
$other = $_POST['other'];


$body = <<<EOD

<br><hr><br>
Contact Information <br>
Name: $name <br>
Company: $company <br>
Phone: $phone <br>
Fax: $fax <br>
Email: $email <br>
Address: $address <br>
Aircraft type: $aircrafttype <br>
Aircraft Model: $aircraftmodel <br>
Aircraft Location : $aircraftlocation <br><br>
Services Requested <br>
Trip Ready Exterior Clean: $CheckBoxServices1 <br>
Trip Ready Interior Clean: $CheckBoxServices2 <br>
Wet Wash: $CheckBoxServices3 <br>
Window Cleaning: $CheckBoxServices4 <br>
Dry Wash: $CheckBoxServices5 <br>
Carpet Extraction: $CheckBoxServices6 <br>
Hand Wax Exterior Paint: $CheckBoxServices7 <br>
Upholstery Dry Cleaning: $CheckBoxServices8 <br>
Machine Buff Exterior Paint: $CheckBoxServices9 <br>
Stain Removal: $CheckBoxServices10 <br>
Brightwork: $CheckBoxServices11 <br>
Fabric Leather Cleaning: $CheckBoxServices12 <br>
De Ice Boots: $CheckBoxServices13
Wood Trim Polishing: $CheckBoxServices14 <br>
Clean Gear Wells: $CheckBoxServices15 <br>
Lavatory Sanitation: $CheckBoxServices16 <br>
PERMAGARD Coating Sealant: $CheckBoxServices17 <br>
Other: $other <br>

EOD;

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

/* Results rendered as HTML */
EOD;

$headers = "From: $email\r\n";

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

$success = mail($webMaster, $emailSubject, $body,

$headers);


$theResults = <<<EOD

<html>

<head>

<title>sent message</title>

<meta http-equiv="refresh" content="2;URL=http://www.amdetailing.com/">

<style type="text/css">

<!--

body {

background-color: #EDF4FF;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 20px;

font-style: normal;

line-height: normal;

font-weight: normal;

color: #000033;

text-decoration: none;

padding-top: 200px;

margin-left: 150px;

width: 800px;

}
-->
</style>
</head>
<div align="center">Your email will be answered soon as possible!
<br/>
You will return to Aircraft Mobile Detailing in a few seconds !</div>
</div>
</body>
</html>

EOD;

echo "$theResults";

?>