Results 1 to 3 of 3

Thread: Mail Problem

  1. #1
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default Mail Problem

    The HTML
    Code:
    <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
    Code:
    <?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
    Last edited by boogyman; 03-10-2007 at 07:15 AM.

  2. #2
    Join Date
    Feb 2007
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You're getting your php syntax confused with javascript syntax.

    Code:
    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)
    Last edited by Blake; 03-10-2007 at 07:13 PM.
    "Rock and roll ain't noise pollution." - AC/DC

    http://www.blake-foster.com

  3. #3
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Its almost the same, but instead of
    var result = "Yes"
    you have
    $result = "Yes";
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •