Chris: Fehler in Datei

Also ich habe jetzt ein Feedback Formular Tutorial gefunden:

<?php

//This is the location of your sendmail variable
    //if you don't know, contact your sysadmin
    $mail_path = "/usr/sbin/sendmail -i -t";

//The email address to be receiving emails from this form
    $mail_to = "zan@stargeek.com";

//the subject of the email sent by the form
    $mail_subject = "Contact Form";

//the name of the buisness or website that the form contacts
    $buisness_name = "Stargeek";

//this is the html of the form used to create the email
    $form_html = '$html = "
                    <h1>
                        To Contact $buisness_name:
                        </h1>
                        <form action="$PHP_SELF" method="post">
                            <table class="mainText" border="0" cellspacing="5">
                                <tr>
                                    <td>Your Name:    </td>
                                    <td>$name </td>
                                </tr>
                                <tr>
                                    <td>Your Email Address:</td>
                                    <td>$reply<td>
                                </tr>
                                <tr>
                                    <td colspan="2" align="center">Your Message</td>
                                </tr>
                                <tr>
                                    <td colspan="2" align="center">$message</td>
                                </tr>
                                <tr>
                                    <td colspan="2"  align="center">$send</td>
                                </tr>
                            </table>
                        </form>
                        Script by <a href="http://www.stargeek.com">Stargeek</a>
            ";';

ini_set("sendmail_from", $mail_from);
    ini_set("sendmail_path", $mail_path);

if ($_POST)
    {
        if($_POST['userEmail'])
        {
            if( mail($mail_to,$mail_subject,"\t From: ".$_POST['userName']."\n \t Email: ".$_POST['userEmail']. "\n\n\n\n".stripslashes($_POST['userMessage']).'this email was generated by <a href="http://www.stargeek.com">Stargeek</a>'s script'.,"From: $_POST[userEmail]\r\n"."Reply-To: $_POST[userEmail]\r\n")  )
            {
                $html  = 'Thank you for contacting '.$buisness_name.', '.$_POST['userName'].'. <br/>Your email was sent <br/>Script by <a href="htp://www.stargeek.com">Stargeek</a>';
            }
            else
            {
                $html = 'There was an error';
            }
        }
    }
    else
    {
        $message = '<textarea name="userMessage" rows="20" cols="70"></textarea>';
        $name = '<input type="text" name="userName" size="30">';
        $reply = '<input type="text" name="userEmail" size="30">';
        $send = '<input type="submit" name="submit" value="Send">';

eval($form_html);
    }
?>

<html>
<head>
<title>-{Title Here}-</title>
</head>
<body>
<?=$html?>
</body>
</html>

alerdings kommen immer wieder Fehler: wie
Parse error: parse error, unexpected T_IF in sendmail.php on line 51
woran liegt das?

  1. //This is the location of your sendmail variable
        //if you don't know, contact your sysadmin
        $mail_path = "/usr/sbin/sendmail -i -t";

    Vergewissere dich mal ob die location von sendmail passt.

  2. Halihallo Chris

    Also ich habe jetzt ein Feedback Formular Tutorial gefunden:

    Schmeiss das Ding weg... Matt Wright für PHP :-(

    //this is the html of the form used to create the email
        $form_html = '$html = "
                        <h1>
                        [...]

    und dann per eval ausführen... Weg damit, aber sehr schnell, damit
    kann u.U. jeder auf deinen Server zugreifen, wenns dumm kommt...

    Merke: eval ist böse[tm]!

    ini_set("sendmail_from", $mail_from);
        ini_set("sendmail_path", $mail_path);

    Warum ggf. bereits sinnvoll gesetzte Werte überschreiben?

    href="http://www.stargeek.com">Stargeek</a>'s script'.,"From:

    ^^^^

    hier ist z.B. ein Fehler. Ich habe jetzt keine Lust noch weitere zu
    suchen. Schau dir einfach den Code nochmals genau an. Eine etwas
    schönere Formatierung wird dir behilflich sein.

    eval($form_html);

    Löse das in deinem eigenen Interesse anders! - Plötzlich schleicht
    sich hier eine Variable rein, die von aussen änderbar ist und somit
    ein arges Sicherheitsrisiko darstellt.

    alerdings kommen immer wieder Fehler: wie
    Parse error: parse error, unexpected T_IF in sendmail.php on line 51
    woran liegt das?

    An Syntaxfehlern, die du bestimmt noch finden wirst. Sieh einfach
    nach, was in der Zeile 51 (ggf. auch einige davor!) steht...

    Viele Grüsse

    Philipp