unable to figure out problem in php code of simple form

Discussion in 'PHP' started by sabahat, Feb 4, 2012.

  1. #1
    <?



    $mailto = 'myemail@gmail.com' ;

    $subject = "Feedback Form" ;

    $formurl = "http://www.domain.com/form.html" ;

    $errorurl = "http://www.domain.com/error.html" ;

    $thankyouurl = "http://www.domain.com/thanks.html" ;


    $uself = 0;



    // -------------------- END OF CONFIGURABLE SECTION ---------------



    $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;

    $name = $_POST['name'] ;
    $email = $_POST['email'];
    $company = $_POST['company'];
    $comments = $_POST['comments']


    $http_referrer = getenv( "HTTP_REFERER" );



    if (!isset($_POST['email'])) {

    header( "Location: $formurl" );

    exit ;

    }

    if (empty($email)) {

    header( "Location: $errorurl" );

    exit ;

    }

    if ( ereg( "[\r\n]", $email ) ) {

    header( "Location: $errorurl" );

    exit ;

    }





    $messageproper =

    "This message was sent from:\n" .
    "$http_referrer\n" .
    "------------------------------------------------------------\n"


    "Name: $name\n"
    "Email: $email\n"
    "Company or brand Name: $company\n"
    "Brief Project Description: $comments\n" .

    "------------------------- Message -------------------------\n\n" .

    "I am subscribing.\n" .

    "Email of sender: $email\n" .

    "\n\n------------------------------------------------------------\n" ;



    mail($mailto, $subject, $messageproper,

    "From: \"$email\" <$email>" . $headersep . "Reply-To: \"$email\" <$email>" . $headersep . "X-Mailer: feedback.php 2.07" );

    header( "Location: $thankyouurl" );

    exit ;


    ?>

    this is the error i get when i click on submit button:
    Parse error: syntax error, unexpected T_VARIABLE in /home/a2124567/public_html/feedback.php on line 15

    plus i am using free webhosting of 000webhost.
    kindly help me out
     
    sabahat, Feb 4, 2012 IP
  2. amaroks

    amaroks Peon

    Messages:
    242
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    replace
    with
    You missed a ;
     
    amaroks, Feb 5, 2012 IP
  3. sabahat

    sabahat Member

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    yeah i did that but this time it is giving error on line 33

    and line 33 is the next line to ['comment']; which is actualy a empty line.

    previously it was giving error on line 15 on which there is a code $uself = 0

    what could be the problem?
     
    sabahat, Feb 5, 2012 IP
  4. amaroks

    amaroks Peon

    Messages:
    242
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    paste your code at pastebin.com and post link to it, this way I can see the code clearly
     
    amaroks, Feb 5, 2012 IP
  5. bogi

    bogi Well-Known Member

    Messages:
    482
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    140
    #5
    Something like this should work. You've just missed a lot of dots and semicolons. Try to organize your code so you can read it better.

    
    <?php
    
    $mailto      = 'myemail@gmail.com';
    $subject     = 'Feedback Form';
    $formurl     = 'http://www.domain.com/form.html';
    $errorurl    = 'http://www.domain.com/error.html';
    $thankyouurl = 'http://www.domain.com/thanks.html';
    $uself       = 0;
    
    // -------------------- END OF CONFIGURABLE SECTION ---------------
    
    $headersep = (!isset($uself) || ($uself == 0)) ? "\r\n" : "\n";
    
    $name     = $_POST['name'] ;
    $email    = $_POST['email'];
    $company  = $_POST['company'];
    $comments = $_POST['comments'];
    
    $http_referrer = getenv('HTTP_REFERER');
    
    if ( !isset($_POST['email']) ) {
        
        header( "Location: $formurl" );
        exit;
    }
    
    if ( empty($email) ) {
        
        header( "Location: $errorurl" );
        exit;
    }
    
    if ( ereg( "[\r\n]", $email ) ) {
        
        header( "Location: $errorurl" );
        exit;
    }
    
    $messageproper  = "This message was sent from:\n";
    $messageproper .= "$http_referrer\n";
    $messageproper .= "------------------------------------------------------------\n";
    $messageproper .= "Name: $name\n";
    $messageproper .= "Email: $email\n";
    $messageproper .= "Company or brand Name: $company\n";
    $messageproper .= "Brief Project Description: $comments\n";
    $messageproper .= "------------------------- Message -------------------------\n\n";
    $messageproper .= "I am subscribing.\n";
    $messageproper .= "Email of sender: $email\n";
    $messageproper .= "\n\n------------------------------------------------------------\n";
    
    $from = "From: \"$email\" <$email>" .$headersep ."Reply-To: \"$email\" <$email>" .$headersep ."X-Mailer: feedback.php 2.07";
    
    mail($mailto, $subject, $messageproper, $from);
    
    header("Location: $thankyouurl");
    exit;
    
    PHP:
    Anyway, you should get rid of ereg in your code as it is deprecated now...
     
    bogi, Feb 5, 2012 IP
  6. sabahat

    sabahat Member

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    yeah i did exactly same but again it is giving me error on different line. i doubt may be its due to the hosting service but my other website contact form is working fine
     
    sabahat, Feb 5, 2012 IP
  7. bogi

    bogi Well-Known Member

    Messages:
    482
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    140
    #7
    Have you copy pasted my code and you're still getting an error? On what line? What is the error message?
     
    bogi, Feb 6, 2012 IP