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

    [php] problemi con una variabile

    aiuto problema variabile
    sto adattando uno script di registrazione utente alle mie esigenze. dopo le opportune modifiche eseguo su easy php 1.7 e mi da un errore di variabile non dichiarata. la variabile in questione e' la act ovevro quelal che nello switch finale decide la funzione da eseguire.spero che qualcuno possa illuminarmi.

    allego il codice:


    codice:
     <?php
    
    
        include "regconfig.php";
    
    
        function index() {
        global $regconfig;
    
        echo "<html>
        <head>
        <title>\$config[title] --- Register</title>
        <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">
        </head>
        <body>
        <form method=\"post\" action=\"\$act=register\">
        <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\" value=\"Register\">
        </form>
        
    
        
    
        <font class=\"text\">
    
        
    
        
    
        </font>
        </body>
        </html>";
        }
    
    
        function register() {
        global $regconfig,$id,$nome,$cognome,$codcli,$username,$password,$password2,$email,$email2;
        mysql_connect($regconfig['sql_host'], $regconfig['sql_username'], $regconfig['sql_password']);
        mysql_select_db($regconfig['sql_database']);
        $query = mysql_query("SELECT * FROM `members` WHERE username='$username'");
        $check = mysql_num_rows($query);
        if ($check == 1) {
        echo "<html>
        <head>
        <title>\$config[title] --- Registration Error</title>
        <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">
        </head>
        <body>
        <font class=\"error\">
        The username \$username already exists in our database!
        </font>
        </body>
        </html>";
        } else {
        if ($password != $password2 or $email != $email2) {
        echo "<html>
        <head>
        <title>\$config[title] --- Registration Error</title>
        <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">
        </head>
        <body>
        <font class=\"error\">
        The Passwords or Emails were not the same. Try again!
        </font>
        </body>
        </html>";
        } else {
        mysql_connect($config['sql_host'], $config['sql_username'], $config['sql_password']);
        mysql_select_db($config['sql_database']);
    
        $result = mysql_query("INSERT INTO `utenti` (email, id, name, surname, cod_cliente, username, password)". "VALUES ('$email','NULL','$nome','$cognome','$codcli','$username','$password')");
        echo "<html>
        <head>
        <title>\$config[title] --- Registration Complete</title>
        <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">
        </head>
        <body>
        <font class=\"success\">
        You are now registered with us! You may <a href=\"login.php\">login</a> now!
        </font>
        </body>
        </html>";
        }
        }
        }
    
    
        switch ($act) {
        case "index":
        index();
        break;
        case "register":
        register();
        break;
        default:
        index();
        }
        ?>

    grazie diego

  2. #2
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    inserisci qst codice prima dello switch:
    codice:
    $act=isset($_GET['act']) ? $_GET['act'] : "";
    think simple think ringo

  3. #3
    cosa fa di preciso il codice che mi hai suggerito di aggiungere?

    scusa la domanda banale ma mi interessa capire.


    diego

  4. #4
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    Originariamente inviato da areuexperienced
    cosa fa di preciso il codice che mi hai suggerito di aggiungere?

    scusa la domanda banale ma mi interessa capire.


    diego
    operatore ternario:
    http://it.php.net/manual/it/language...comparison.php

    funzione isset:
    www.php.net/isset
    think simple think ringo

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.