Log in

View Full Version : Mail Problem



boogyman
03-10-2007, 07:03 AM
The HTML


<form name="contact" method="post" action="contact.php" onreset="confirm('Reset Form? \nOK for yes CANCEL for no')">

<fieldset>
<legend>Contact</legend>
<dl>
<dt><label for="name">Name:</label></dt>
<dd><input name="name" type="text" value="Josh" /></dd>

<dt><label for="email">Email:</label></dt>
<dd><input name="email" type="text" value="josh@text.com" /></dd>


<dt><label for="yourURL">Your URL:</label></dt>
<dd><input name="yourURL" type="text" value="test.com" /></dd>

<dt><label for="subject">Subject:</label></dt>
<dd><input name="subject" type="text" value="Testing" /></dd>

<dt><label for="msg">Comments:</label></dt>
<dd><textarea name="msg" wrap="soft" cols="25" rows="5">Comments Here</textarea></dd>

<input type="submit" value="Send" />

<input type="reset" value="Clear" />
</dl>
<p>* Designates required field</p>
</fieldset>
</form>



The PHP - extracted from contact.php


<?php
function validText($text) {
var $trimmed = trim(strtolower(strip_tags($text)));
var $safe = ereg_replace("[[:space:]]+", " ", $trimmed);
return substr($safe, 1, 50);
}
function htmlFriendly($text) {
var $trimmed = trim(strtolower(htmlentities(($text)));
var $safe = ereg_replace("[[:space:]]+", " ", $trimmed);
return substr($safe, 1, 1024);
}
$username = validText($_REQUEST['name']);
$url = validText($_REQUEST['yourURL']);
$Subject = validText($_REQUEST['subject']);
$message = htmlFriendly($_REQUEST['msg']);
$headers = '
From: $name - $email
CC: $email
';

$To = "webmaster@dividinglimits.com";
$From = htmlFriendly('email');
$Body = '
From: $username - URL: $url
Subject: $subject
Message: $msg
';

if(mail($To, $Subject, $Body, $Headers)) {
echo "

Thank You {$name} for your comments! You are not being redirected
" header(Location: /index.html); echo "— Click Here if you dont want to wait —"; } else { echo "

Unable to send
";
}
?>


Giving me the error: Parse error: syntax error, unexpected T_VAR in /home/dividinglimits.com/contact.php on line 3
I double and tripled checked the variables and they are all assigned correctly unless i am blind :( If you can spot where its expecting the variable I would appreciate it. I do not see anything on line 3 (highlighted) or anywhere else in the code.

I also tried to pass thru $var and $value as the argument but both of those gave me the same error

any help would be appreciated

Blake
03-10-2007, 06:58 PM
You're getting your php syntax confused with javascript syntax.



var $trimmed = trim(strtolower(strip_tags($text)));


is not the correct way to declare a variable. (same problem on the next line, and in the htmlFriendly function)

boxxertrumps
03-10-2007, 07:32 PM
Its almost the same, but instead of
var result = "Yes"
you have
$result = "Yes";