my php script of my email form is giving me an error

Part of my php script in my email form is throwing out an error and i can't figure it out
Parse error: syntax error, unexpected T_STRING in /home/content/64/11583764/html/summer/test2/contact.php on line 25

I am attaching my file
contact.php
imagekrazyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Please use the code snippet feature to post code here at EE, thanks.

<?php 
if(array_key_exists('send',$_POST)){
	$to = 'circleimage@gmail.com';
	$subject = 'Feedback from aummer rain wellness page';
	
	//process the $_POST variables
	$name = $_POST['name'];
	$email = $_POST['email'];
	$comments = $_POST['comments'];
	
	//build the message
	$message = "Name: $name\n\n";
	$message .= "Email: $email\n\n";
	$message .= "Comments: $comments";
	
	//limit line length to 70 characters
	$message = "wordwrap($message,70);
	
	$mailSent = mail($to, $subject, $message);
}
?>
<!DOCTYPE HTML>
<head>
<title>Untitled Document</title>
<link href="contactStyle.css" rel="stylesheet" type="text/css" media="screen">
</head>
<body>

<div id="header">
    <h1>Summer Rain Wellness</h1>
</div>
<div id="wrapper">
<?php include('includes/menu.inc.php'); ?>

    <div id="maincontent">
      <h2>Contact Us </h2>
      <?php
	  if ($_POST && #mailSent){
		  ?>
          <p class="warning">Sorry, there was a problem sending your message. Please try later.</p>
          <?php
	  }
	  elseif ($_POST && $mailSent) {
		  ?>
          <p><strong>Your message has been sent, thank you for your fed back</strong></p>
          <?php } ?>
      <p>Ut enim ad minim veniam, quis nostrud exercitation consectetur adipisicing elit. Velit esse cillum dolore ullamco laboris nisi in reprehenderit in voluptate. Mollit anim id est laborum. Sunt in culpa duis aute irure dolor excepteur sint occaecat.</p>
        <form id="feedback" method="post" action="">
            <p>
                <label for="name">Name:</label>
                <input name="name" id="name" type="text" class="formbox">
            </p>
            <p>
                <label for="email">Email:</label>
                <input name="email" id="email" type="text" class="formbox">
            </p>
            <p>
                <label for="comments">Comments:</label>
              <textarea name="comments" id="comments" cols="60" rows="8"></textarea>
            </p>
            <p>
                <input name="send" id="send" type="submit" value="Send message">
            </p>
        </form>
      
    </div>
    <?php include('includes/footer.inc.php'); ?>
</div>
</body>
</html>

Open in new window


In the instant case, line 25 contains this:

<link href="contactStyle.css" rel="stylesheet" type="text/css" media="screen">

and that is not a PHP Parse Error.  Please reduce the problem to the SSCCE and use the code snippet to show us what is still giving you trouble.
0
imagekrazyAuthor Commented:
Hi, i can't understand why it stating  Parse error


<?php
if(array_key_exists('send',$_POST)){
      $to = 'circleimage@gmail.com';
      $subject = 'Feedback from aummer rain wellness page';
      
      //process the $_POST variables
      $name = $_POST['name'];
      $email = $_POST['email'];
      $comments = $_POST['comments'];
      
      //build the message
      $message = "Name: $name\n\n";
      $message .= "Email: $email\n\n";
      $message .= "Comments: $comments";
      
      //limit line length to 70 characters
      $message = "wordwrap($message,70);
      
      $mailSent = mail($to, $subject, $message);
}
?>
<!DOCTYPE HTML>
<head>
<title>Untitled Document</title>
<link href="contactStyle.css" rel="stylesheet" type="text/css" media="screen">
</head>
0
Ray PaseurCommented:
Please use the CODE SNIPPET feature!  You can find this by clicking "Code" in the gray bar above the "Post a Comment" area.  The line numbers and the exact code are important if we are to be able to help you.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

imagekrazyAuthor Commented:
<?php 
if(array_key_exists('send',$_POST)){
	$to = 'circleimage@gmail.com';
	$subject = 'Feedback from aummer rain wellness page';
	
	//process the $_POST variables
	$name = $_POST['name'];
	$email = $_POST['email'];
	$comments = $_POST['comments'];
	
	//build the message
	$message = "Name: $name\n\n";
	$message .= "Email: $email\n\n";
	$message .= "Comments: $comments";
	
	//limit line length to 70 characters
	$message = "wordwrap($message,70);
	
	$mailSent = mail($to, $subject, $message);
}
?>
<!DOCTYPE HTML>
<head>
<title>Untitled Document</title>
<link href="contactStyle.css" rel="stylesheet" type="text/css" media="screen">
</head>
<body>

Open in new window

0
Ray PaseurCommented:
OK, thanks for that.  And what is the error message and what is the line number?
0
Dave BaldwinFixer of ProblemsCommented:
Even when the error goes away, it will probably bounce because the proper headers are not being used.  I can show you a demo, Ray has one too.
0
Ray PaseurCommented:
At Gmail, it will probably go in the spam folder until the recipient white-lists the sending domain.  

I'm a little more concerned that we still do not have the correct script in front of us.  For better or worse, computer programming is something that requires exacting precision and when I see "summer" spelled "aummer" it always makes me itch, wondering what else might be a little bit off.
0
imagekrazyAuthor Commented:
it saying syntax error at line 26 but i looked at that line and I attached a css file so what did I do wrong?
<?php 
if(array_key_exists('send',$_POST)){
	$to = '';
	$subject = 'Feedback from aummer rain wellness page';
	
	//process the $_POST variables
	$name = $_POST['name'];
	$email = $_POST['email'];
	$comments = $_POST['comments'];
	
	//build the message
	$message = "Name: $name\n\n";
	$message .= "Email: $email\n\n";
	$message .= "Comments: $comments";
	
	//limit line length to 70 characters
	$message = "wordwrap($message,70);
	
	$mailSent = mail($to, $subject, $message);
}
?>
<!DOCTYPE HTML>
<head>
<title>Untitled Document</title>

<link href="css/contactStyle.css" rel="stylesheet" type="text/css">
</head>

Open in new window

0
Ray PaseurCommented:
I believe it is an extraneous quote mark in line 17.

PHP can make these sorts of things devilishly hard to find.  I found it by going to the end of the PHP script and removing all of the extraneous HTML.  The next message was "unexpected $end" and I've made that mistake about a hundred times before, so I knew to look for unbalanced control structures or unbalanced quotes.  Since there was only one control structure (defined by the {} curly braces), I used a "find" function in my text editor to look for ", trying to match paired quotation marks.  Et voila.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
Lest your script come under attack and become an open-relay for spam, please learn about the principles of filtering and sanitizing the external variables.
http://php.net/manual/en/language.variables.external.php
http://php.net/manual/en/security.php

Here is a code snippet that will work correctly.   Maybe you can start from here and build up your own application.

<?php // RAY_form_to_email.php
error_reporting(E_ALL);


// SEND MAIL FROM A FORM


// REQUIRED VALUES ARE PREPOPULATED - CHANGE THESE FOR YOUR WORK
$from = 'NoReply@Your.org';
$subj = 'Contact Form';

// THIS IS AN ARRAY OF RECIPIENTS - CHANGE THESE FOR YOUR WORK
$to[] = 'You@Your.org';
$to[] = 'Her@Your.org';
$to[] = 'Him@Your.org';
$to[] = 'Ray.Paseur@Gmail.com';


// IF THE DATA HAS BEEN POSTED (AT LEAST SOMETHING IN THE EMAIL INPUT CONTROL)
if (!empty($_POST['e']))
{
    // CLEAN UP THE POTENTIALLY BAD AND DANGEROUS DATA
    $safe_mail = clean_string($_POST['e']);
    $safe_name = clean_string($_POST['n']);
    $safe_fone = clean_string($_POST['t']);
    $save_idea = clean_string($_POST['i']);

    // CONSTRUCT THE MESSAGE THROUGH STRING CONCATENATION
    $content    = NULL;
    $content   .= "You have a New Query From $safe_name" . PHP_EOL . PHP_EOL;
    $content   .= "Tel No: $safe_fone" . PHP_EOL;
    $content   .= "Email: $safe_mail" . PHP_EOL;

    // SEND MAIL TO EACH RECIPIENT
    foreach ($to as $recipient)
    {
        if (!mail( $recipient, $subj, $content, "From: $from\r\n"))
        {
            echo PHP_EOL . "<br/>MAIL FAILED FOR $recipient";
        }
        else
        {
            echo PHP_EOL . "<br/>MAIL WORKED FOR $recipient";
        }
    }

    // PRODUCE THE THANK-YOU PAGE
    echo '<p>THANK YOU</p>' . PHP_EOL;
    die('TASK COMPLETE');
}


// A FORM TO TAKE CLIENT INPUT FOR THIS SCRIPT
$form = <<<ENDFORM
<form method="post">
Please enter your contact information
<br/>Email: <input name="e" />
<br/>Phone: <input name="t" />
<br/>Name:  <input name="n" />
<br/>Ideas? <textarea name="i"></textarea>
<br/><input type="submit" />
</form>
ENDFORM;

echo $form;


// A FUNCTION TO CLEAN UP THE DATA - AVOID BECOMING AN OPEN-RELAY FOR SPAM
function clean_string($str)
{
    // IF MAGIC QUOTES IS ON, WE NEED TO REMOVE SLASHES
    $str = stripslashes($str);

    // REMOVE EXCESS WHITESPACE
    $rgx
    = '#'                // REGEX DELIMITER
    . '\s'               // MATCH THE WHITESPACE CHARACTER(S)
    . '\s+'              // MORE THAN ONE CONTIGUOUS INSTANCE OF WHITESPACE
    . '#'                // REGEX DELIMITER
    ;
    $str = preg_replace($rgx, ' ', $str);

    // REMOVE UNWANTED CHARACTERS
    $rgx
    = '#'                // REGEX DELIMITER
    . '['                // START OF A CHARACTER CLASS
    . '^'                // NEGATION - MATCH NONE OF THE CHARACTERS IN THIS CLASS
    . 'A-Z0-9'           // KEEP LETTERS AND NUMBERS
    . '"'                // KEEP DOUBLE QUOTES
    . "'"                // KEEP SINGLE QUOTES
    . '@&+:?_.,/\-'      // KEEP SOME SPECIAL CHARACTERS (ESCAPED HYPHEN)
    . ' '                // KEEP BLANKS
    . ']'                // END OF THE CHARACTER CLASS
    . '#'                // REGEX DELIMITER
    . 'i'                // CASE-INSENSITIVE
    ;
    $str = preg_replace($rgx, NULL, $str);

    // REMOVE EXCESSIVE INPUT
    $str = substr($str, 0, 255);

    return trim($str);
}

Open in new window

HTH, ~Ray
0
imagekrazyAuthor Commented:
Wow, thank you very much, it works. and thank you for that example!
0
Ray PaseurCommented:
Thanks for the points!  Good luck with the project, ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.