Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2009
    Messaggi
    14

    Problema Script PHP/mySQL

    ho questo codice che non mi dà nessun tipo di ERROR ma una volta compilati i campi (username&password) e schiacciato il button del login, mi ritorna nella pagina stessa con i campi vuoti senza darmi nessun errore..le tabelle sql sono corrette...sto veramente impazzendo...PLEASE HELP ME

    Codice PHP:
    <?php
    if(!isset($_SESSION)){ 
    session_start (); 
    }
    ?>


    <?php

    if( isset($_POST['submit_x']) && (trim($_POST['submit_x'] == "invia")))

      if((!isset(
    $_POST['username'])) || ($_POST['username'] == ""))
      {
        echo 
    "Attenzione, username non corretto!";
      }
      elseif((!isset(
    $_POST['password'])) || ($_POST['password'] == "") || (!preg_match("/^[a-z0-9]+$/i"$_POST['password'])))
      {
        echo 
    "Attenzione, password non corretta.";
      }else{
        
    $username $_POST['username'];
        
    $password $_POST['password'];

        include_once 
    "connect.php";

        
    $ctrl_login mysql_query("SELECT id FROM iscrizioni WHERE username='$username' AND password='$password'") or die (mysql_error());
        if(
    mysql_num_rows($ctrl_login)==0)
        {
          echo 
    "Login incorretto.";
        }else{
          
    $obj mysql_fetch_array($ctrl_login) or die (mysql_error());
          (
    $obj['id']);
          
    $_SESSION['id'] = $obj['id'];
          (
    $_SESSION['id']);
          
    header("Location: iscritti.php");
        }
      } 
    }else{
    ?>
    <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
    <p align="center" style="margin-top: -20px; margin-bottom: 0">
    [img]username.gif[/img]

    <input name="username" type="text" size="20">

    [img]password.gif[/img]

    <input name="password" type="password" size="20"></p>
    <p align="center" style="margin-top: -8px; margin-bottom: 0">

    <input name="submit" type="image" src="buttonlogin.gif"> 
    <a href="registrazione.php">
    [img]buttonregister.gif[/img]</a></p>
    <p align="center" style="margin-top: -8px; margin-bottom: 0"></p>
    <p align="center" style="margin-top: -8px; margin-bottom: 0"><u>
    <font size="1" color="#0000FF" face="Arial">[url="richiesta_password.php"]&gt;&gt;[/url]</font><a href="richiesta_password.php"><font face="Tahoma" size="1" color="#0000FF"> 
    hai dimenticato la password?</font></a></u></p>
    </form>
    <?
    }
    ?>
    Qulcuno mi può aiutare?

  2. #2
    Utente di HTML.it L'avatar di carlo2002
    Registrato dal
    Jun 2002
    Messaggi
    2,746
    A prima vista noto che fai un controllo sulla variabile $_POST['submit_x'] il cui valore dovrebbe essere 'invia', invece il name dell'input submit all'interno del form è 'submit' e non c'è il value.

    Errare humanum est, perseverare ovest

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.