kleines Session problem

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

  • kleines Session problem

    also ich hab ein formular mit captcha
    das über Session geht
    ich krige immer diesen Warning

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at ..........................bestell.php:2) in ..........................bestell.php on line 4


    aber so geht alles

    hab es schon mit

    Quellcode

    1. error_reporting(E_ALL);
    versucht wegzumachen aber die Warning kommt immernoch :(

    kann mir einer helfen ?

    MFG
    OverSave
  • allso hier ist mal alles ^^


    bestell.php

    Quellcode

    1. <div align="center">
    2. <?php
    3. error_reporting(E_ALL);
    4. session_start();
    5. if ( ! isset ($_POST['bestell']))
    6. {
    7. echo "<form method='POST' action='" . $_SERVER['PHP_SELF'] . "'>
    8. <div align='center'>
    9. Name: <input type='text' name='name' size='30' maxlength='60'><p>
    10. Passwort: <input type='password' name='pass' size='30' maxlength='60'><p>
    11. E-Mail: <input type='text' name='mail' size='30' maxlength='60'><p>
    12. <img src='captcha.php' border='0' alt='captcha'><br>
    13. Code: <input name='captcha' size='30' type='text'><p>
    14. <p><input type='submit' value='Bestellen' name='bestell' style='background-color:#ffffff;color:#000000'></p></div>
    15. </form>";
    16. }
    17. else
    18. {
    19. if($_POST['name'] == "")
    20. {
    21. echo "Bitte gib ein Name an";
    22. }
    23. else
    24. {
    25. if($_POST['pass'] == "")
    26. {
    27. echo "Bitte gib ein Passwort an";
    28. }
    29. else
    30. {
    31. if($_POST['mail'] == "")
    32. {
    33. echo "Bitte gib eine E-Mail Adresse an";
    34. }
    35. else
    36. {
    37. if ( md5($_POST['captcha']) == $_SESSION['captcha'] )
    38. {
    39. echo "alles ok";
    40. }
    41. else
    42. {
    43. echo "Code ist falsch";
    44. }
    45. }
    46. }
    47. }
    48. }
    49. ?>
    50. </div>
    51. <style type="text/css"><!-- A {text-decoration: none}--></style>
    52. <body bgcolor="#ffffff" text="#000000" Link="#000000" ALink="#000000" VLink="#000000">
    Alles anzeigen


    captcha.php

    Quellcode

    1. <?PHP
    2. session_start();
    3. $alphanum = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    4. $code = substr( str_shuffle( $alphanum ), 0, 5 );
    5. $_SESSION['captcha'] = md5( $code );
    6. $image = imagecreatefromjpeg( 'captcha.jpg');
    7. $bgCol = imagecolorallocate ( $image, 255, 255, 255 );
    8. $txtCol = imagecolorallocate ( $image, 0, 0, 0 );
    9. imagestring ( $image, 5, 5, 8, $code, $txtCol );
    10. header( 'Expires: Mon, 12 Jul 1999 01:01:00 GMT' );
    11. header( 'Last-Modified: ' . gmdate( "D, d M Y H:i:s" ) . ' GMT' );
    12. header( 'Cache-Control: no-store, no-cache, must-revalidate' );
    13. header( 'Cache-Control: post-check=0, pre-check=0', false );
    14. header( 'Pragma: no-cache' );
    15. header( 'Content-type: image/jpeg' );
    16. imagejpeg( $image );
    17. imagedestroy( $image );
    18. ?>
    Alles anzeigen
  • "Trekkie" schrieb:

    Wo die Session gestartet wird ist egal, solange die Session nicht automatisch einen Keks setzen will. Daran scheitert es in diesem Beispiel, nicht an der Session ansich.


    Nicht ganz! Will man Objekte in der Session speichern, müssen die Klassen vor dem Session-Start eingebunden werden. ;)

    70abc
    We raise hopes, here ... until they're old enough to fend for themselves.
    - Mike Callahan