...

View Full Version : form problem php



newtocode
10-10-2009, 06:04 PM
Form Problem with php get this error code when space words also when don't my space them some thing are not showing.

How can space them and get each area to show in the email

Here the part that are not showing in email

Firstname:
Lastname:
Email: myemail@live.com
Supporttype:
Other:
Comments: hi

here the code I get when space names and support type
Parse error: syntax error, unexpected T_STRING in /home/a9375737/public_html/contactformprocess.php on line 9


HTML Code

<!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>Northern Region Freight Contact US</title>
<style type="text/css">
<!--
body {
background-color: #386643;
background-image: url(images/bg1.gif);
background-repeat: repeat-x;
}
-->
</style>
<link href="css/layout.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="wrapper">
<div id="logo"><img src="images/NRFlogo.jpg" alt="NRFlogo" width="980" height="200" /></div>
<div id="navigation"></div>
<div id="bodyArea">
<div id="content"> <p align="center">&nbsp;</p>
<form action="contactformprocess.php" method="post" name="form1" id="form1">
<p align="left"><strong> FirstName * </strong> </p>
<p align="left">
<input name="first name" type="text" id="first name" size="35" />
</p>
<p align="left">&nbsp;</p>
<p align="left"><strong>Last Name* </strong></p>
<p align="left">
<input name="last name" type="text" id="last name" size="35" />
</p>
<p align="left">&nbsp;</p>
<p align="left"><strong>Email *</strong></p>
<p align="left">
<input name="email" type="text" id="email" size="35" />
</p>
<p align="left">&nbsp;</p>
<p align="left"><strong>Please Select Type of Support From list below</strong></p>
<p align="left">
<select name="support type" id="support type">
<option selected="selected">Select one</option>
<option value="Question">Question</option>
<option value="Technical Support">Technical Support</option>
<option value="Other">Other</option>
</select>
</p>
<p align="left">&nbsp;</p>
<p align="left"><strong>IF other please type it below</strong></p>
<p align="left">
<input name="other" type="text" id="other" size="35" />
</p>
<p align="left">&nbsp;</p>
<p align="left">
<textarea name="comments" id="comments" cols="45" rows="5"></textarea>
</p>
<p align="left">&nbsp;</p>
<p align="left">
<input type="submit" name="submit" id="submit" value="Submit" />
<input type="reset" name="reset" id="reset" value="Reset" />
</p>
<p>&nbsp;</p>
</form>

<p>&nbsp;</p>
</div>
<div id="footer"></div>
</div>
</div>
</body>
</html>


PHP code

<?php
/* Subject and Email Veriables */

$emailSubject = "Northern Region Freight Contact US";
$webMaster = "usatrucker20076@yahoo.com";

/* Gathering Data Veriables */

$first nameField = $_POST['first name'];
$last nameField = $_POST['last name'];
$emailField = $_POST['email'];
$support typeField = $_POST['support type'];
$otherField = $_POST['other'];
$commentsField = $_POST['comments'];

$body = "";
$body .= "<br>";
$body .= "<hr>";
$body .= "<br>";
$body .= "First name: " . $_POST['first name'] . "<br>\n";
$body .= "Last name: " . $_POST['last name'] . "<br>\n";
$body .= "Email: " . $_POST['email'] . "<br>\n";
$body .= "Support type: " . $_POST['support type'] . "<br>\n";
$body .= "Other: " . $_POST['other'] . "<br>\n";
$body .= "Comments: " . $_POST['comments'] . "<br>\n";

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

/* Results rendered as HTML */

$theResults = <<<EOD2
<!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>Northern Region Freight </title>
<style type="text/css">
<!--
body {
background-color: #386643;
background-image: url(images/bg1.gif);
background-repeat: repeat-x;
}
-->
</style>
<link href="css/layout.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="wrapper">
<div id="logo"><img src="images/NRFlogo.jpg" alt="NRFlogo" width="980" height="200" /></div>
<div id="navigation"></div>
<div id="bodyArea">
<div id="content">
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">Thank you For your interest in Northern Region Freight we will </p>
<p align="center">get back to you with 24 hours of submission.</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><br />
</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
</div>
<div id="footer"></div>
</div>
</div>
</body>
</html>

EOD2;

echo $theResults;

?>

met
10-10-2009, 06:42 PM
spaces in your variable names == bad

use underscores or camelcase in your HTML and php instead of spaces or you will get parse errors

newtocode
10-10-2009, 06:59 PM
also why when don't space it is some of the feild not show like name support and question

it look like this when get the email even those fill in everything.
Firstname:
Lastname:
Email: myemail@live.com
Supporttype:
Other:
Comments: hi

met
10-10-2009, 07:02 PM
<?php
/* Subject and Email Veriables */

$emailSubject = "Northern Region Freight Contact US";
$webMaster = "usatrucker20076@yahoo.com";

/* Gathering Data Veriables */

$firstnameField = $_POST['firstname'];
$lastnameField = $_POST['lastname'];
$emailField = $_POST['email'];
$supporttypeField = $_POST['supporttype'];
$otherField = $_POST['other'];
$commentsField = $_POST['comments'];

$body = "";
$body .= "<br>";
$body .= "<hr>";
$body .= "<br>";
$body .= "First name: " . $firstnameField . "<br>\n";
$body .= "Last name: " . $lastnameField . "<br>\n";
$body .= "Email: " . $emailField . "<br>\n";
$body .= "Support type: " .$supporttypeField. "<br>\n";
$body .= "Other: " . $otherField . "<br>\n";
$body .= "Comments: " . $commentsField . "<br>\n";

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


/* Results rendered as HTML */

$theResults = <<<EOD2
<!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>Northern Region Freight </title>
<style type="text/css">
<!--
body {
background-color: #386643;
background-image: url(images/bg1.gif);
background-repeat: repeat-x;
}
-->
</style>
<link href="css/layout.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="wrapper">
<div id="logo"><img src="images/NRFlogo.jpg" alt="NRFlogo" width="980" height="200" /></div>
<div id="navigation"></div>
<div id="bodyArea">
<div id="content">
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">Thank you For your interest in Northern Region Freight we will </p>
<p align="center">get back to you with 24 hours of submission.</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><br />
</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
</div>
<div id="footer"></div>
</div>
</div>
</body>
</html>

EOD2;

echo $theResults;

?>




<!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>Northern Region Freight Contact US</title>
<style type="text/css">
<!--
body {
background-color: #386643;
background-image: url(images/bg1.gif);
background-repeat: repeat-x;
}
-->
</style>
<link href="css/layout.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="wrapper">
<div id="logo"><img src="images/NRFlogo.jpg" alt="NRFlogo" width="980" height="200" /></div>
<div id="navigation"></div>
<div id="bodyArea">
<div id="content"> <p align="center">&nbsp;</p>
<form action="contactformprocess.php" method="post" name="form1" id="form1">
<p align="left"><strong> FirstName * </strong> </p>
<p align="left">
<input name="firstname" type="text" id="firstname" size="35" />
</p>
<p align="left">&nbsp;</p>
<p align="left"><strong>Last Name* </strong></p>
<p align="left">
<input name="lastname" type="text" id="lastname" size="35" />
</p>
<p align="left">&nbsp;</p>
<p align="left"><strong>Email *</strong></p>
<p align="left">
<input name="email" type="text" id="email" size="35" />
</p>
<p align="left">&nbsp;</p>
<p align="left"><strong>Please Select Type of Support From list below</strong></p>
<p align="left">
<select name="supporttype" id="supporttype">
<option selected="selected">Select one</option>
<option value="Question">Question</option>
<option value="Technical Support">Technical Support</option>
<option value="Other">Other</option>
</select>
</p>
<p align="left">&nbsp;</p>
<p align="left"><strong>IF other please type it below</strong></p>
<p align="left">
<input name="other" type="text" id="other" size="35" />
</p>
<p align="left">&nbsp;</p>
<p align="left">
<textarea name="comments" id="comments" cols="45" rows="5"></textarea>
</p>
<p align="left">&nbsp;</p>
<p align="left">
<input type="submit" name="submit" id="submit" value="Submit" />
<input type="reset" name="reset" id="reset" value="Reset" />
</p>
<p>&nbsp;</p>
</form>

<p>&nbsp;</p>
</div>
<div id="footer"></div>
</div>
</div>
</body>
</html>

newtocode
10-10-2009, 07:22 PM
it did not work those spot still not showing can't figure this out.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum