Emailprüfung

  • PHP

  • reny
  • 1006 Aufrufe 2 Antworten

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Emailprüfung

    Hi ich habe vor ein Emailprüfscript in eine Website einzubauen (für Feedback).
    Doch ich habe mehrere Probleme:

    form.php:

    PHP-Quellcode

    1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    2. <html xmlns="http://www.w3.org/1999/xhtml">
    3. <head>
    4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    5. <title>Unbenanntes Dokument</title>
    6. <?php session_start();
    7. ?>
    8. </head>
    9. <body>
    10. <form id="form1" name="form1" method="post" action="pruefen.php">
    11. <p>
    12. <label>E-Mail
    13. <input type="text" name="email" id="email" />
    14. </label>
    15. </p>
    16. <p>
    17. <label>
    18. <input type="submit" name="button" id="button" value="Pruefen" />
    19. </label>
    20. </p>
    21. </form>
    22. </body>
    23. </html>
    Alles anzeigen


    Problem:

    Quellcode

    1. Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/emailpruefen/form.php:6) in /Applications/XAMPP/xamppfiles/htdocs/emailpruefen/form.php on line 6
    2. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Applications/XAMPP/xamppfiles/htdocs/emailpruefen/form.php:6) in /Applications/XAMPP/xamppfiles/htdocs/emailpruefen/form.php on line 6


    pruefen.php:

    PHP-Quellcode

    1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    2. <html xmlns="http://www.w3.org/1999/xhtml">
    3. <head>
    4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    5. <title>Unbenanntes Dokument</title>
    6. <?PHP
    7. //session_start();
    8. $wert=rand(1, 1000000);
    9. $_SESSION['wertesession'] = $wert;
    10. $_SESSION['mail']=$_POST[email];
    11. echo $wert;
    12. if ($_POST[email]) {
    13. // hier steht der mail-Befehl zum Versenden
    14. mail($_POST[email],"",$wert);
    15. echo "Erfolgreich verschickt";
    16. } else {
    17. echo "Bitte geben Sie etwas ein";
    18. }
    19. ?>
    20. </head>
    21. <body>
    22. <form id="form1" name="form1" method="post" action="testen.php">
    23. <p>
    24. <label>Code:
    25. <input type="text" name="code" id="textfield" />
    26. </label>
    27. </p>
    28. <p>
    29. <label>Text:
    30. <textarea name="nachricht" id="textarea" cols="45" rows="5"></textarea>
    31. </label>
    32. </p>
    33. <p>
    34. <label>
    35. <input type="submit" name="button" id="button" value="Weiter" />
    36. </label>
    37. </p>
    38. </form>
    39. </body>
    40. </html>
    Alles anzeigen


    KEIN Problem

    testen.php:

    PHP-Quellcode

    1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    2. <html xmlns="http://www.w3.org/1999/xhtml">
    3. <head>
    4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    5. <title>Unbenanntes Dokument</title>
    6. <?PHP
    7. // hier steht der mail-Befehl zum Versenden
    8. if($_SESSION['wertesession']==$_POST[text] && $_POST[nachricht]){
    9. mail("email@test.de","Nachricht von $_SESSION['mail']",$_POST[nachricht]);
    10. echo "Erfolgreich verschickt";
    11. }
    12. session_destroy();
    13. ?>
    14. </head>
    15. <body>
    16. </body>
    17. </html>
    Alles anzeigen


    Problem:

    Quellcode

    1. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /Applications/XAMPP/xamppfiles/htdocs/emailpruefen/testen.php on line 10



    danke schonmal
    xnu&#305;l feel free
    &#477;ldd&#592; feel different
    s&#653;opu&#305;&#653; feel bad
  • Moin,

    das Problem liegt daran, dass das session_start() immer vor einer Ausgabe stehen muss.
    =>

    PHP-Quellcode

    1. <?php session_start(); ?>
    2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    3. <html xmlns="http://www.w3.org/1999/xhtml">
    4. <head>
    5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    6. <title>Unbenanntes Dokument</title>
    7. ...
    Rechteübersicht * Forenregeln * F.A.Q. * Lexikon
    Suchfunktion * Chat * User helfen User
    Patrioten reden nur davon, dass sie für ihr Land sterben, niemals davon, dass sie für ihr Land töten. (Bertrand Russell)
  • nun habe ich ein anderes problem beim testen.php mit dem löschen der session


    Warning:Trying to destroy uninitialized session in testen.php on line 1

    mod:bitte vorherigen post löschen versehentlich geschehen

    form.php

    PHP-Quellcode

    1. <?php session_start(); ?>
    2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    3. <html xmlns="http://www.w3.org/1999/xhtml">
    4. <head>
    5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    6. <title>Unbenanntes Dokument</title>
    7. </head>
    8. <body>
    9. <form id="form1" name="form1" method="post" action="pruefen.php">
    10. <p>
    11. <label>E-Mail
    12. <input type="text" name="email" id="email" />
    13. </label>
    14. </p>
    15. <p>
    16. <label>
    17. <input type="submit" name="button" id="button" value="Pruefen" />
    18. </label>
    19. </p>
    20. </form>
    21. </body>
    22. </html>
    Alles anzeigen



    Problem:

    Quellcode

    1. Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at form.php:6) in form.php on line 6
    2. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at form.php:6) in form.php on line 6
    xnu&#305;l feel free
    &#477;ldd&#592; feel different
    s&#653;opu&#305;&#653; feel bad

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Broken Sword ()