Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Oct 2014
    Posts
    7
    Member #
    40491

    Help with php coding error

    This is what the php looks like:

    <?php
    if(isset($_POST['email'])) {

    // CHANGE THE TWO LINES BELOW
    $email_to = "bryanleichter@gmail.com";`

    $email_subject = "Comment about ShyOrange.com";


    function died($error) {
    // your error code can go here
    echo "We are very sorry, but there were error(s) found with the form you submitted. ";
    echo "These errors appear below.<br /><br />";
    echo $error."<br /><br />";
    echo "Please go back and fix these errors.<br /><br />";
    die();
    }

    // validation expected data exists
    if(!isset($_POST['first_name']) ||!isset($_POST['last_name']) ||
    !isset($_POST['email']) ||
    !isset($_POST['comments'])) {
    died('We are sorry, but there appears to be a problem with the form you submitted.');
    }

    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $comments = $_POST['comments']; // required

    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
    if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
    }
    $string_exp = "/^[A-Za-z .'-]+$/";
    if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
    }
    if(!preg_match($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
    }
    if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
    }
    if(strlen($error_message) > 0) {
    died($error_message);
    }
    $email_message = "Form details below.\n\n";

    function clean_string($string) {
    $bad = array("content-type","bcc:","to:","cc:","href");
    return str_replace($bad,"",$string);
    }

    $email_message .= "First Name: ".clean_string($first_name)."\n";
    $email_message .= "Last Name: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Comments: ".clean_string($comments)."\n";


    // create email headers
    $headers = 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
    @mail($email_to, $email_subject, $email_message, $headers);
    ?>

    <!-- place your own success html below -->

    Thank you for contacting us. We will be in touch with you very soon.

    <?php
    }
    die();
    ?>

    I keep getting the following error and I don't know what it means. Any help would be great.

    Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /homepages/24/d548336522/htdocs/html_form_send.php on line 20

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Could you post the form HTML?
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Junior Member
    Join Date
    Oct 2014
    Posts
    7
    Member #
    40491
    Sure, here is the form HTML:
    <form name="htmlform" method="post" action="html_form_send.php">
    <table width="450px">
    </tr>
    <tr>
    <td valign="top">
    <label for="first_name">First Name</label>
    </td>
    <td valign="top">
    <input type="text" name="first_name" maxlength="50" size="30">
    </td>
    </tr>

    <tr>
    <td valign="top"">
    <label for="last_name">Last Name</label>
    </td>
    <td valign="top">
    <input type="text" name="last_name" maxlength="50" size="30">
    </td>
    </tr>
    <tr>
    <td valign="top">
    <label for="email">Email Address</label>
    </td>
    <td valign="top">
    <input type="text" name="email" maxlength="80" size="30">
    </td>

    <tr>
    <td valign="top">
    <label for="comments">Comment</label>
    </td>
    <td valign="top">
    <textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea>
    </td>

    </tr>
    <tr>
    <td colspan="2" style="text-align:center">
    <input type="submit" value="Submit">
    </td>
    </tr>
    </table>
    </form>

  5. #4
    Senior Member sasha_bolcina's Avatar
    Join Date
    Sep 2014
    Location
    Serbia
    Posts
    274
    Member #
    40099
    Liked
    47 times
    There is wrong char in $email_to = "bryanleichter@gmail.com";`
    The char at the end of line, after ; is wrong
    Line should be:
    $email_to = "bryanleichter@gmail.com";

    When I change it, code start working and sending emails.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:33 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com