Issues with form checker having '@' in eval code

Discussion in 'PHP' started by citacomp, Jun 29, 2009.

  1. #1
    I am trying to have a user fill in a form, a page checks to see if the required fields are filled, then that page emails the information to us and displays a confirmation. We do not want a javascript checker right now. I have attached some of the code from the check/email page. The error I am recieving is: "Parse error: syntax error, unexpected '@' in ... : eval()'d code on line 1.


    $to = "email@address.com";
    $subject = "subject line";
    $message = "message with some of the variables being outputted too.";
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
    $headers .= 'From: <another@email.com>' . "\r\n";
    
    if(!$fullname || !$email)
    { echo ("You have not filled in all required fields");
       exit;
    }
    else {
       echo('<fieldset style="width:600px" align="center"><legend>Confirmation</legend><br /> Thank You.</fieldset>');
       eval("mail($to,$subject,$message,$headers);"); 
    }
    Code (markup):

     
    citacomp, Jun 29, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Is there a reason why you are using eval and not just mail()?

    From the code posted, there's no reason to use eval at all?
     
    jestep, Jun 29, 2009 IP
  3. citacomp

    citacomp Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I dont know what I was thinking yesterday. I saw the same thing once I looked at the code this morning. Thanks for the help.
     
    citacomp, Jun 30, 2009 IP