Visualizzazione dei risultati da 1 a 5 su 5

Discussione: errore session_start()

  1. #1

    errore session_start()

    ciao a tutti, ho il file registrati.php con il seguente codice:

    <center>
    <?

    # Hier ggf. den Header einfügen!


    if ($anmelden) { anmelden($fertig, $user, $password1, $password2, $email);}
    else if ($abmelden) { abmelden($fertig, $user, $password);}
    else if ($forgot) { forgot($fertig, $email);}
    else { login($fertig, $user, $password);}


    # hier ggf. den Footer einfügen!

    ?>
    <?
    function inhalt($user)
    {
    session_start();
    session_register("user");


    ##################################
    #Bauen Sie hier Ihren Inhalt ein!#
    # #
    ?>


    [img]images/index_02.gif[/img][img]images/index_04.gif[/img]</p>


    </p><h5 align="center"><a href="http://www.pm25.it/contatti.php">Vai alla pagina
    contatti</a>

    <?
    # #
    # Ab hier nichts mehr ändern! #
    ##################################


    }
    ?>
    <?
    function login($fertig, $user, $password)
    {
    include("config.php");

    if ($fertig) {

    $abfrage = mysql_query ("SELECT * FROM login WHERE user = '$user'");
    $reihen = mysql_num_rows($abfrage);
    if ($reihen <= 0) {
    echo "Username sconosciuto!";
    }
    else {
    while ($row = mysql_fetch_object ($abfrage)) {
    if ($row->password==$password) {
    inhalt($user);
    }
    else {
    echo "Password errata!";
    }
    }
    }

    }

    else {
    echo "Per la registrazione <a href=\"$PHP_SELF?anmelden=yes\">Qui</a>";
    echo "

    <h2>Login</h2></p>";

    echo "<form method=\"POST\" action=\"$PHP_SELF?fertig=yes\">";
    ?>
    </h5>
    <table border="0" align="center" cellpadding="2" cellspacing="1">
    <tr>
    <td><font size="2">Username:</font></td>
    <td><font size="2"><input type="text" name="user" value=""></font></td>
    </tr>
    <tr>
    <td><font size="2">Passwort:</font></td>
    <td><font size="2"><input type="password" name="password" value=""></font></td>
    </tr>
    <tr>
    <td colspan=2 align=center><input type=submit value=Login></td>
    </tr>
    </table>
    </form>
    <?
    echo "

    <a href=\"$PHP_SELF?forgot=yes\">Password dimenticata?</a>
    <a href=\"$PHP_SELF?abmelden=yes\">Esci</a></p>";
    }

    }
    ?>
    <?
    function anmelden ($fertig, $user, $password1, $password2, $email)
    {
    include("config.php");

    if($fertig) {
    $abfrage1 = mysql_query("SELECT user FROM login");
    while ($row = mysql_fetch_object ($abfrage1)) {
    if ($row->user==$user) {
    echo "Username già esistente!";
    exit;
    }
    }
    if ($user=="" OR $password1=="" OR $password2=="" or $email=="") {
    echo "Non avete compilato tutti i campi!";
    }
    else if ($password1!=$password2) {
    echo "Le due password non sono uguali!";
    }
    else {
    $anfuegen=mysql_query("INSERT INTO login (user, password, email) VALUES ('$user','$password1', '$email')");
    echo "Registrazione avvenuta con successo! Potete fare il login:
    ";
    @login();
    }
    }
    else {
    echo "<h2>Login</h2>";
    echo "<form method=\"POST\" action=\"$PHP_SELF?anmelden=yes&fertig=yes\">";
    ?>
    <div align="center"></div>
    <div align="center"></div>
    <table cellspacing="1" cellpadding="2" border="0">
    <tr>
    <td><font size="2">Username:</font></td>
    <td><font size="2"><input type="text" name="user" value=""></font></td>
    </tr>
    <tr>
    <td><font size="2">Passwort:</font></td>
    <td><font size="2"><input type="password" name="password1" value=""></font></td>
    </tr>
    <tr>
    <td><font size="2">Ripeti Pass:</font></td>
    <td><font size="2"><input type="password" name="password2" value=""></font></td>
    </tr>
    <tr>
    <td><font size="2">E-Mail:</font></td>
    <td><font size="2"><input type="text" name="email" value=""></font></td>
    </tr>
    <tr>
    <td colspan=2 align=center><input type=submit value=Registrati></td>
    </tr>
    </table>
    </form>
    <?
    }

    }
    ?>




    <?
    function forgot ($fertig, $email)
    {

    include("config.php");

    if ($fertig) {
    $abfrage=mysql_query("SELECT * FROM login");
    while ($row = mysql_fetch_object ($abfrage)) {
    if ($email==$row->email) { $ismail="true"; }
    }
    if ($ismail=="true") {
    $password=mysql_query("SELECT * FROM login WHERE email = '$email'");
    while ($row = mysql_fetch_object ($password)) {
    $nachricht="Ciao $row->user!\n\nLa tua password è:\n\n$row->password\n\nMfG\nAdmin";
    }
    mail($email, "Passwort", $nachricht, "From: info@pm25.it");
    ?>


    La passwort vi e' stata spedita al vostro indirizzo email <? echo $email; ?>


    Non dimenticarti la passwort per entrare.</p>

    <?

    @login();
    }
    else { echo "Indirizzo email non trovato!";}
    }
    else {

    echo "

    <h2>Password dimenticata</h2>

    ";
    echo "

    <form method=post action=\"$PHP_SELF?forgot=yes&fertig=yes\">";
    ?>
    <table cellspacing="1" cellpadding="2" border="0">
    <tr>
    <td><font size="2">E-Mail:</font></td>
    <td align=center><input type=text name=email></td></tr>
    <tr><td colspan="2" align=center><input type=submit value="Rimanda!"></td></tr>
    </table></form></p>
    <?
    }
    }
    ?>



    <?
    function abmelden($fertig, $user, $password)
    {

    include ("config.php");

    if($fertig) {
    $abfrage = mysql_query ("SELECT * FROM login WHERE user = '$user'");
    $reihen = mysql_num_rows($abfrage);
    if ($reihen <= 0) {
    echo "Username sconosciuto!";
    }
    else {
    while ($row = mysql_fetch_object ($abfrage)) {
    if ($row->password==$password) {
    $delete = mysql_query ("DELETE FROM login WHERE user = '$user'");
    echo "I vostri dati sono stati cancellati dal database!";
    }
    else {
    echo "Password sbagliata!";
    }
    }
    }

    }
    else {
    echo "

    <h2>Esci</h2></p>";
    echo "<form method=\"POST\" action=\"$PHP_SELF?abmelden=yes&fertig=yes\">";
    ?>
    <table cellspacing="1" cellpadding="2" border="0">
    <tr>
    <td><font size="2">Username:</font></td>
    <td><font size="2"><input type="text" name="user" value=""></font></td>
    </tr>
    <tr>
    <td><font size="2">Passwort:</font></td>
    <td><font size="2"><input type="password" name="password" value=""></font></td>
    </tr>
    <tr>
    <td colspan=2 align=center><input type=submit value=Esci></td>
    </tr>
    </table>
    </form>
    <?
    }

    }
    ?>


    [img]images/index_47.gif[/img]</p>
    </center>
    ----------------------------------------------------------------
    Quando faccio il login mi esce il seguente errore:

    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/mhd-01/www.pm25.it/htdocs/registrati.php:2) in /home/mhd-01/www.pm25.it/htdocs/registrati.php on line 19

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/mhd-01/www.pm25.it/htdocs/registrati.php:2) in /home/mhd-01/www.pm25.it/htdocs/registrati.php on line 19

    Mi sapete dire come mai esce quest'errore?
    grazie in anticipo

  2. #2
    Utente di HTML.it L'avatar di zakros
    Registrato dal
    Oct 2000
    Messaggi
    509
    session_start() va messo in cima allo script prima subito dopo <?php mentre il tuo script inizia con <center>

  3. #3
    ciao zakros e grazie per la risposta. Io lo avevo messo all'inizio ma mi dava sempre quell errore con riga diversa ovviamente, il <center >io lo avevo messo perche mi dovrebbe uscire tutto centrato e non a sinistra infatti lo avevo chiuso a fine script . ci sara un altro errore?

  4. #4
    Utente di HTML.it L'avatar di zakros
    Registrato dal
    Oct 2000
    Messaggi
    509
    Devi togliere il center all inizio, nn ci possono essere output ne righe vuote prima di lanciare session o cookie, stampalo dopo session_start() con un echo"<center>";

  5. #5
    grazie zakros, adesso mi funziona bene.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.