Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    [PHP SCRIPT] problema con variabili

    sto creando uno script di registrazione utenti e dopo aver creato il mio bel form con metodo post e action registra creo la pagina register.php.

    il problema e' il seguente: lo script mi da errore di variabile non definita su tutte le variabili passate dal form.

    cosa sbaglio?

    ecco lo script.

    codice:
    <html>
    <head>
    <style type="text/css">
    
    </style>
    </head>
    <body>
    <?php
    include "regconfig.php";
    if(isset($_POST['action']) and $_POST['action'] == 'registra'){
    	mysql_connect($regconfig['sql_host'], $regconfig['sql_username'], $regconfig['sql_password']);
    	mysql_select_db($regconfig['sql_database']);
    		$query = mysql_query("SELECT * FROM `utenti` WHERE username='$username'");
    		$check = mysql_num_rows($query);
    			if ($check == 1) {
    				echo "
    				<font class=\"error\">
    				The username \$username already exists in our database!
    				</font>
    				</body>
    				</html>";
    } else {
    		if ($password != $password2 or $email != $email2) {
    				echo "
    				<font class=\"error\">
    				The Passwords or Emails were not the same. Try again!
    				</font>
    				</body>
    				</html>";
    } else {
    		mysql_connect($regconfig['sql_host'], $regconfig['sql_username'], $regconfig['sql_password']);
    		mysql_select_db($regconfig['sql_database']);
            $query = "INSERT INTO utenti (email, name, surname, cod_cliente, username, password) VALUES ('$email','$nome','$cognome','$codcli','$username','$password')";
         mysql_query($query);
    	
    	
    	
    	
    	echo "
    	<font class=\"success\">
        \$email \$nome \$cognome \$codcli \$username \$password
    	You are now registered with us! You may <a href=\"home.php\">login</a> now!
    	</font>
    	</body>
    	</html>";
    		}
    	}
    }
    ?>

    ciao grazie

  2. #2
    da dove arriva $username?
    ***************************************
    the fate of all mankind i see is in the hands of fool
    ---peter sinfield----

  3. #3
    dal form

  4. #4
    ecco i lform:



    <html>
    <head>
    <title>Registrazione utente</title>
    <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body>
    <form method="post" action="register.php">
    <table width="800" border="0" cellspacing="0" cellpadding="3" style="border-collapse: collapse" bordercolor="#111111" class="text">

    <tr>
    <td width="100">Nome:</td>
    <td width="180"><input type="text" name="nome" size="30"></td>
    </tr>

    <tr>
    <td width="100">Cognome:</td>
    <td width="180"><input type="text" name="cognome" size="30"></td>
    </tr>

    <tr>
    <td width="100">Codice Cliente:</td>
    <td width="180"><input type="text" name="codcli" size="100"></td>
    </tr>
    <tr>
    <td width="100">Username:</td>
    <td width="180"><input type="text" name="username" size="20"></td>
    </tr>
    <tr>
    <td width="100">Password:</td>
    <td width="180"><input type="password" name="password" size="20"></td>
    </tr>
    <tr>
    <td width="100">Password Again:</td>
    <td width="180"><input type="password" name="password2" size="20"></td>
    </tr>
    <tr>
    <td width="100">Email:</td>
    <td width="180"><Input type="text" name="email" size="20"></td>
    </tr>
    <tr>
    <td width="100">Email Again:</td>
    <td width="180"><input type="text" name="email2" size="20"></td>
    </tr>



    </table>
    <input type="submit" name="action" value="registra">
    </form>




    <font class="text">





    </font>
    </body>
    </html>

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 © 2024 vBulletin Solutions, Inc. All rights reserved.