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

Thread: PHP help please

  1. #1
    Junior Member
    Join Date
    Oct 2005
    Location
    GA
    Posts
    14
    Member #
    11505
    When submitting the following form I receive a few error messages that read "parse error, unexpected (symbol)" I am using the following, Ive looked over this and messed with the syntax but am trying to learn as I go .

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

        
    $email_to "";
        
    $email_subject "Customer $name requested a quote";

        function 
    died($error) {
            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();
        }

        if(!isset(
    $_POST['name']) ||
        !isset(
    $_POST['email']) ||
        !isset(
    $_POST['phone']) ||
        !isset(
    $_POST['message']) {
            
    died('We are sorry, but there appears to be a problem with the form you submitted.');
        }

        
    $name $_POST['name'];
        
    $phone $_POST['phone'];
        
    $email $_POST['email'];
        
    $company $_POST['company'];
        
    $message $_POST['message'];

        
    $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,$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($message) < 2) {
        
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
      }
      if(
    strlen($error_message) > 0) {
        
    died($error_message);
      }
        
    $email_message "Customer quote:\n\n";

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

      
    $email_message .= "Name: ".clean_string($name)."\n";
      
    $email_message .= "Company: ".clean_string($company)."\n";
      
    $email_message .= "Phone: ".clean_string($phone)."\n";
      
    $email_message .= "E-Mail: ".clean_string($email)."\n";
      
    $email_message .= "Message: ".clean_string($message)."\n";

    $headers 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n".
    'X-Mailer: PHP/' phpversion();
    @
    mail($email_to$email_subject$email_message$headers);
    echo 
    "Thank you for your business. An associate will assist you shortly.";

    ?>
    -------------------------------------------------

    HTML Code:
    <form name="contactform" method="post" action="yonderway.php">
    <table width="450px">
    <tr>
    <td valign="top">  <label for="name">Name *</label>  </td>
    <td valign="top">  <input  type="text" name="name" maxlength="50" size="30">  </td>
    </tr>
    <tr>
    <td valign="top">  <label for="company">Company</label>
    </td>
    <td valign="top">  <input  type="text" name="company" maxlength="50" size="30">  </td>
    </tr>
    <tr>  <td valign="top">  <label for="email">Email</label>
    </td>  <td valign="top">
    <input  type="text" name="email" maxlength="80" size="30">
    </td>
    </tr>
    <tr>
    <td valign="top">
    <label for="phone">Phone:</label>
    </td>
    <td valign="top">
    <input  type="text" name="telephone" maxlength="30" size="30">
    </td>
    </tr>
    <tr>
    <td valign="top">  <label for="message">Message: *</label>
    </td>
    <td valign="top">  <textarea  name="message" 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>
    ----------

    Any help on this is appreciated, thanks.

    ----------

    Other question is once I create a list on the html side, I would like the user to be able to select multiple items from the list but be able to choose different amounts. eg apples 12, oranges 10, etc. Have this added with their info. Something like:

    PHP Code:
    $email_message .= "Apple: ".clean_string($fruit_apple)."\n";
    $email_message .= "Orange: ".clean_string($fruit_orange)."\n"
    I am looking for the most straight forward way to knock this out. THANK YOU

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,716
    Member #
    5580
    Liked
    718 times
    If you download Notepad++ (it's free, search for it on Google) to edit your scripts,
    you'll see that it numbers the lines, and shows opening and closing tags, brackets, parenthesis.

    I found the missing ) really quick using Notepad++ .. the red one below is missing on your script. ...

    if(!isset($_POST['name']) ||
    !isset($_POST['email']) ||
    !isset($_POST['phone']) ||
    !isset($_POST['message'])) {
    died('We are sorry, but there appears to be a problem with the form you submitted.');
    }

    There may be other syntax errors, but that is one I saw right away ...


  4. #3
    Junior Member
    Join Date
    Oct 2005
    Location
    GA
    Posts
    14
    Member #
    11505
    Thank you for the suggestion. I was able to fix a couple of the errors but now when I hit the send button it just goes to the php page and displays the script. Any suggestions on that?

  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,716
    Member #
    5580
    Liked
    718 times
    Is this on your own server?
    If so, you don't have PHP installed or enabled.
    If you're using an online shared webhost, then you have an issue with them.

    You should never be seeing the actual PHP script when you
    access it using a browser. It should either be the PHP script
    executed results, or an error message (from the server).

    If your extension is .php , then it should be executed as a PHP script.
    That's a server configuration issue.



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 03:18 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com