Ok, I'm trying this new email PHP script out. Although I'm pretty new to PHP, it looks easy enough, but I have to admit, I'm not exactly sure what I'm supposed to be looking for. I'm getting the following errors:
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /var/www/vhosts/***.com/httpdocs/php/contactus.php on line 116
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/vhosts/***.com/httpdocs/php/contactus.php on line 116Line 116 is pointed out below
Could it be the server can't handle PHP? I've ran into that issue before. What am I missing?
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>Untitled Document</title>
<style type="text/css">
<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #FFFFFF;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
}
.oneColFixCtr #container {
width: 780px; /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
}
.oneColFixCtr #mainContent {
padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
.style3 { font-family:Veranda,Arial, Helvetica, sanserif; font-size: 9pt; color:333333;}
-->
</style></head>
<body class="oneColFixCtr">
<div id="container">
<div id="mainContent"><?php
// Web form spammers frequently either leave HTTP_REFERER empty, set it
// equal to the form's own URL, or make something up out of thin air.
// We don't do this "is it our own server" if it's blank, as the "is it
// blank" check will get that one
$selfChkStr = $_SERVER['PHP_SELF'];
$serverChkStr = "http://" . $_SERVER['SERVER_NAME'];
if(($chkFormRefNotBlank && !$_SERVER['HTTP_REFERER']) ||
($chkFormRefNotSelf && preg_match("#$selfChkStr$#i", $_SERVER['HTTP_REFERER'])) ||
($chkFormRefOwnServer && $_SERVER['HTTP_REFERER'] &&
!preg_match("#^$serverChkStr#i", $_SERVER['HTTP_REFERER'])))
{
// Almost certainly web form spammers - let 'em wait for it;)
sleep(10);
// Crude, very crude (gracefully "terminate" the page early)
print("<div align=\"center\"><font color=\"red\">Disallowed HTTP Referer! ("" .
$_SERVER['HTTP_REFERER'] .
"")</font></div>");
print("</body></html>");
exit;
}
if($requireVerify)
print("<div align=\"center\"><font color=\"red\">Cookies must be enabled to use this form.</font></div><p />");
?>
<div align="center" width="700"><table><tr><td width="47"><table>
<tr>
<td align="right"><span class="style3"> Send To: </span></td>
<td align="left">
<?php
// Get a pseudo-random alpha-numeric string (no zeros and O's)
function pseudo_random_string($length) {
$string = "";
while($length--) {
for($indx = rand(49, 90);
($indx > 57 && $indx < 65) || $indx == 79;
$indx = rand(49, 90))
;
$string .= chr($indx);
}
return($string);
}
// Read a line from a config file, stripping comments
// and blank lines
function read_file_line($fp) {
while(($inString = fgets($fp, 2048)) != false) {
$inString = rtrim(preg_replace('/\s*#.*/', '',
$inString));
if(!empty($inString))
break;
}
return $inString;
}
if(!$HTTP_SESSION_VARS['majik_string'])
$HTTP_SESSION_VARS['majik_string'] = pseudo_random_string(5);
// Read the contact list keys and descriptions into hash
if(($fp = fopen($recipientFile, "r")) == false) {
die("Can't open data file '$recipientFile'.\n");
}
while($inString = read_file_line($fp)) {
list($key, $description, $value) =
explode(':', $inString);
$options[$key] = $description;
}
fclose($fp);
// If we've more than one choice: present a menu
if(count($options) > 1) {
// If we were given a single arg, that'll be the
// selected menu item.
if(count($_GET) == 1)
$selected = strtolower(key($_GET));
print("<select name=\"whoto\">\n");
foreach($options as $key => $description) {
print("<option ");
if(strtolower($key) == $selected)
print("selected ");
Line 116 ------> print("value=\"" . trim($key) . \">" .
trim($description) . "\n");
}
print("</select>\n");
} else {
// There'll be only one...
foreach($options as $key => $description) {
print("<input type=\"hidden\" name=\"whoto\" value=\"" .
trim($key) . "\">" . trim($description) . "\n");
}
}
// Used by the form processor acknowledgment to create a
// "take me back" link.
if(!empty($_SERVER['HTTP_REFERER'])) {
print("<input type=\"hidden\" name=\"orig_referer\" value=\"" .
$_SERVER['HTTP_REFERER'] . "\">\n");
}
?>
</td>
</tr>
<tr>
<td align="right"><span class="style3"> Your name: </span></td>
<td align="left"><input type="text" name="name" size="30" />
</td>
</tr>
<tr>
<td align="right" class="style3"> Email address: </td>
<td align="left"><input type="text" name="email" size="30" />
</td>
</tr>
<tr>
<td align="right" class="style3"> Subject: </td>
<td align="left"><input type="text" name="subject" size="30" />
</td>
</tr>
<?php
// Are we requiring CAPTCHA-style "is a human" verification?
if($requireVerify) {
print <<<End_Of_Data
<tr><td> </td></tr>
<tr>
<td colspan="2">
Please enter the verification string on the right into the box on the left.
</td>
</tr>
<tr>
<td align="right">
Verification:
</td>
<td align="left">
<input type="text" name="verify" size=10>
<img src="scfgenimg.php" width="60" height="20" align="top" alt="Verification string image"/>
</td>
</tr>
End_Of_Data;
}
?>
</table></td>
<td width="423"><form action="scformproc.php" method="post">
<p class="style3"> <span class="style3">Please enter your comments below. Click "Submit" when done. </span><br />
<textarea name="comments" rows=10 cols=50></textarea>
</p>
<p>
<input type="submit" name="s" value="Send" size="20" />
</p>
</form></td>
</tr></table>
</div>
</body>
</html>
</th>
</tr>
<!-- end #mainContent --></div>
<!-- end #container --></div>
</body>
</html>