Jump to content

Submit on contact form showing white screen with parse error, please help!


sicawebd

Recommended Posts

Hi,

 

Ive recently started up my own small business doing web design for personal wedding invites. Im still quite new at everything, however now that i’ve got my first website invite up and running the contact form doesnt seem to work, i got this form from a tutorial I did when i was first started learning dreamweaver so i cant pick up where i’ve gone wrong. When i click send it comes up with a white screen with the error "Parse error: syntax error, unexpected T_STRING in /home/content/43/10414143/html/form.php on line 22"

 

html is as follows:

 

 

<div id="rsvp-form-2">

<form class="required-form" action="form.php" method="post"><ol class="forms">

<li><label for="rsvp">Yes / No</label><input type="text" name="rsvp" id="name" /></li>

<li><label for="name">Name</label><input type="text" name="name" id="name" /></li>

<li><label for="name">Guest Name</label><input type="text" name="name" id="name" /></li>

<li><label for="email">Email</label><input type="text" name="email" id="email" /></li>

<li><label for="phone">Phone</label><input type="text" name="phone" id="phone" /></li>

<li><label for="message">Message</label><textarea name="message" id="message"></textarea></li>

<li class="buttons"><button type="submit" style="background: none; border: 0px;"><img src="Images/RSVP/send.gif" /></button></li>

<li class="buttons submit"><input type="submit" value="submit" /></li>

<li class="buttons reset"><input type="reset" value="reset" /></li>

</ol>

</form>

</div>

 

I also have a validate.js and css with the following script in my header:

 

<script type="text/javascript">

$(document).ready(function() {

$('form.required-form').simpleValidate({

errorElement: 'em'

});

});

</script>

 

and php is as follows:

 

<?php

 

// This work is licensed under the MIT License - http://www.opensource.org/licenses/mit-license.php

 

 

// OPTIONS - PLEASE CONFIGURE THESE BEFORE USE!

 

$yourEmail = "rsvp@claireanddane.com"; //

$yourWebsite = "http://www.claireanddane.com"; //

$thanksPage = 'thanks.html'; //

$maxPoints = 4; //

 

 

$error_msg = null;

$result = null;

 

function isBot() {

$bots = array("Indy", "Blaiz", "Java", "libwww-perl", "Python", "OutfoxBot", "User-Agent", "PycURL", "AlphaServer", "T8Abot", "Syntryx", "WinHttp", "WebBandit", "nicebot");

 

$isBot = false;

foreach ($bots as $bot)

if (strpos($_SERVER['HTTP_USER_AGENT'], $bot) !== false)

$isBot = true;

 

if (empty($_SERVER['HTTP_USER_AGENT']) || $_SERVER['HTTP_USER_AGENT'] == " ")

$isBot = true;

 

exit("Bots not allowed.</p>");

}

 

if ($_SERVER['REQUEST_METHOD'] == "POST") {

function clean($data) {

$data = trim(stripslashes(strip_tags($data)));

return $data;

}

 

$points = (int)0;

 

$badwords = array("adult", "beastial", "bestial", "blowjob", "clit", "cum", "cunilingus", "cunillingus", "cunnilingus", "cunt", "ejaculate", "fag", "felatio", "fellatio", "fuck", "fuk", "fuks", "gangbang", "gangbanged", "gangbangs", "hotsex", "hardcode", "jism", "jiz", "orgasim", "orgasims", "orgasm", "orgasms", "phonesex", "phuk", "phuq", "porn", "pussies", "pussy", "spunk", "xxx", "viagra", "phentermine", "tramadol", "adipex", "advai", "alprazolam", "ambien", "ambian", "amoxicillin", "antivert", "blackjack", "backgammon", "texas", "holdem", "poker", "carisoprodol", "ciara", "ciprofloxacin", "debt", "dating", "porn", "link=", "voyeur");

$exploits = array("content-type", "bcc:", "cc:", "document.cookie", "onclick", "onload", "javascript");

 

foreach ($badwords as $word)

if (strpos($_POST['comments'], $word) !== false)

$points += 2;

 

foreach ($exploits as $exploit)

if (strpos($_POST['comments'], $exploit) !== false)

$points += 2;

 

if (strpos($_POST['comments'], "http://") !== false || strpos($_POST['comments'], "www.") !== false)

$points += 2;

if (isset($_POST['nojs']))

$points += 1;

if (preg_match("/(<.*>)/i", $_POST['comments']))

$points += 2;

if (strlen($_POST['name']) < 3)

$points += 1;

if (strlen($_POST['comments']) < 15 || strlen($_POST['comments'] > 1500))

$points += 2;

 

foreach ($_POST as $key => $value)

$_POST[$key] = trim($value);

 

if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comments'])) {

$error_msg .= "Name, e-mail and comments are required fields. \n";

} elseif (strlen($_POST['name']) > 15) {

$error_msg .= "The name field is limited at 15 characters. Your first name or nickname will do! \n";

} elseif (!preg_match("/^[a-zA-Z-'\s]*$/", stripslashes($_POST['name']))) {

$error_msg .= "The name field must not contain special characters. \n";

} elseif (!preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', strtolower($_POST['email']))) {

$error_msg .= "That is not a valid e-mail address. \n";

} elseif (!empty($_POST['url']) && !preg_match('/^(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i', $_POST['url']))

$error_msg .= "Invalid website url.";

 

if ($error_msg == NULL && $points <= $maxPoints) {

$subject = "Automatic Form Email";

 

$message = "You received this e-mail message through your website: \n\n";

foreach ($_POST as $key => $val) {

$message .= ucwords($key) . ": " . clean($val) . "\r\n";

}

$message .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n";

$message .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n";

$message .= 'Points: '.$points;

 

if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {

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

$headers .= "Reply-To: {$_POST['email']}";

} else {

$headers = "From: $yourWebsite <$yourEmail> \r\n";

$headers .= "Reply-To: {$_POST['email']}";

}

 

if (mail($yourEmail,$subject,$message,$headers)) {

if (!empty($thanksPage)) {

header("Location: $thanksPage");

exit;

} else {

$result = 'Your mail was successfully sent.';

}

} else {

$error_msg = 'Your mail could not be sent this time.';

}

} else {

if (empty($error_msg))

$error_msg = 'Your mail looks too much like spam, and could not be sent this time. ['.$points.']';

}

}

function get_data($var) {

if (isset($_POST[$var]))

echo htmlspecialchars($_POST[$var]);

}

?>

 

 

website for reference is http://www.claireanddane.com

 

Any advice would be appreciated as i’ve tried everything!

 

Jessica

Link to comment
Share on other sites

Personally, I would always use curlry braces for if, foreach, switch etc statements..

 

So in your case:

foreach ($bots as $bot){
 if (strpos($_SERVER['HTTP_USER_AGENT'], $bot) !== false){
   $isBot = true;
 }
}

This way there is no guessing as to what code belongs in which block etc.. Give that a try and see if the error message moves to another line lower down.

 

Denno

Edited by denno020
Link to comment
Share on other sites

var_dump($_SERVER);

 

Oh hold on.. perhaps you can do this instead:

 

foreach ($bots as $bot){
 if (in_array($_SERVER['HTTP_USER_AGENT'], $bot)) {
   $isBot = true
 }
}

 

That will search the array $bots with the value of HTTP_USER_AGENT

Edited by denno020
Link to comment
Share on other sites

var_dump($_SERVER);

 

Oh hold on.. perhaps you can do this instead:

 

foreach ($bots as $bot){
if (in_array($_SERVER['HTTP_USER_AGENT'], $bot)) {
$isBot = true
}
}

 

That will search the array $bots with the value of HTTP_USER_AGENT

 

Apologies, I have steered you wrong with this code, it should have been

if (in_array($_SERVER['HTTP_USER_AGENT'], $bots)) {
$isBot = true
}

Link to comment
Share on other sites

"Parse error: syntax error, unexpected T_STRING in /home/content/43/10414143/html/form.php on line 22"

 

Is the PHP you showed above the file named in that error message? I did not get a Parse error when I tried that code.

 

Note: The in_array code will NOT produce the same results as the strpos code. The original code is searching the entire UA for the existence of any of the bot strings anywhere in the UA. The in_array() code is only checking to see if the UA is exactly equal to one of the bot strings.

 

It's a mute point, because 1) that function is not called in the code provided; and 2) that function will always execute the exit("Bots not allowed.</p>"); line whether it finds a bot string or not!

 

 

Show us the form.php file, or check line 22 of that file yourself. That is where the problem lies.

 

Oh, and use

 

tags, it makes the code easier to read.

Link to comment
Share on other sites

Yes it is that file. i’ve tried it again this morning with the original form.php file i used (which is same as below) and its now coming up just a blank screen with no errors.

 

<?php
// This work is licensed under the MIT License - http://www.opensourc...mit-license.php
// OPTIONS - PLEASE CONFIGURE THESE BEFORE USE!
$yourEmail = "rsvp@claireanddane.com"; //$yourWebsite = "http://www.claireanddane.com"; //$thanksPage = 'thanks.html'; //$maxPoints = 4; //
$error_msg = null;$result = null;
function isBot() {$bots = array("Indy", "Blaiz", "Java", "libwww-perl", "Python", "OutfoxBot", "User-Agent", "PycURL", "AlphaServer", "T8Abot", "Syntryx", "WinHttp", "WebBandit", "nicebot");
$isBot = false;foreach ($bots as $bot)if (strpos($_SERVER['HTTP_USER_AGENT'], $bot) !== false)$isBot = true;
if (empty($_SERVER['HTTP_USER_AGENT']) || $_SERVER['HTTP_USER_AGENT'] == " ")$isBot = true;
exit("Bots not allowed.</p>");}
if ($_SERVER['REQUEST_METHOD'] == "POST") {function clean($data) {$data = trim(stripslashes(strip_tags($data)));return $data;}
$points = (int)0;
$badwords = array("adult", "beastial", "bestial", "blowjob", "clit", "cum", "cunilingus", "cunillingus", "cunnilingus", "cunt", "ejaculate", "fag", "felatio", "fellatio", "fuck", "fuk", "fuks", "gangbang", "gangbanged", "gangbangs", "hotsex", "hardcode", "jism", "jiz", "orgasim", "orgasims", "orgasm", "orgasms", "phonesex", "phuk", "phuq", "porn", "pussies", "pussy", "spunk", "xxx", "viagra", "phentermine", "tramadol", "adipex", "advai", "alprazolam", "ambien", "ambian", "amoxicillin", "antivert", "blackjack", "backgammon", "texas", "holdem", "poker", "carisoprodol", "ciara", "ciprofloxacin", "debt", "dating", "porn", "link=", "voyeur");$exploits = array("content-type", "bcc:", "cc:", "document.cookie", "onclick", "onload", "javascript");
foreach ($badwords as $word)if (strpos($_POST['comments'], $word) !== false)$points += 2;
foreach ($exploits as $exploit)if (strpos($_POST['comments'], $exploit) !== false)$points += 2;
if (strpos($_POST['comments'], "http://") !== false || strpos($_POST['comments'], "www.") !== false)$points += 2;if (isset($_POST['nojs']))$points += 1;if (preg_match("/(<.*>)/i", $_POST['comments']))$points += 2;if (strlen($_POST['name']) < 3)$points += 1;if (strlen($_POST['comments']) < 15 || strlen($_POST['comments'] > 1500))$points += 2;
foreach ($_POST as $key => $value)$_POST[$key] = trim($value);
if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comments'])) {$error_msg .= "Name, e-mail and comments are required fields. \n";} elseif (strlen($_POST['name']) > 15) {$error_msg .= "The name field is limited at 15 characters. Your first name or nickname will do! \n";} elseif (!preg_match("/^[a-zA-Z-'\s]*$/", stripslashes($_POST['name']))) {$error_msg .= "The name field must not contain special characters. \n";} elseif (!preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', strtolower($_POST['email']))) {$error_msg .= "That is not a valid e-mail address. \n";} elseif (!empty($_POST['url']) && !preg_match('/^(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(\d+))?\/?/i', $_POST['url']))$error_msg .= "Invalid website url.";
if ($error_msg == NULL && $points <= $maxPoints) {$subject = "Automatic Form Email";
$message = "You received this e-mail message through your website: \n\n";foreach ($_POST as $key => $val) {$message .= ucwords($key) . ": " . clean($val) . "\r\n";}$message .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n";$message .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n";$message .= 'Points: '.$points;
if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {$headers   = "From: $yourEmail \r\n";$headers  .= "Reply-To: {$_POST['email']}";} else {$headers   = "From: $yourWebsite <$yourEmail> \r\n";$headers  .= "Reply-To: {$_POST['email']}";}
if (mail($yourEmail,$subject,$message,$headers)) {if (!empty($thanksPage)) {header("Location: $thanksPage");exit;} else {$result = 'Your mail was successfully sent.';}} else {$error_msg = 'Your mail could not be sent this time.';}} else {if (empty($error_msg))$error_msg = 'Your mail looks too much like spam, and could not be sent this time. ['.$points.']';}}function get_data($var) {if (isset($_POST[$var]))echo htmlspecialchars($_POST[$var]);}?>

Edited by sicawebd
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.