Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Nuovo problema

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2006
    Messaggi
    108

    Nuovo problema

    Il codice qui sotto sembra funzionare se non che quando vado ad inserire tutti i dati del form costruito, restituisce il seguente errore

    You have an error in your SQL syntax near '='pampa'' at line 1

    dove pampa è il nome che io assegno allo username.




    <html>
    <head>
    <title>Registrazione</title>
    <meta http-equiv="content-type"
    content="text/html; charset=iso-8859-1" />
    </head>
    <body>
    <h1>First Access</h1>

    <?php

    //Connessione a MySql.
    include $_SERVER['localhost'].'/includes/connect_Mysql.inc.php';

    //Creazione del DB Fantacalcio.
    include $_SERVER['localhost'].'/includes/create_DB.inc.php';

    //Selezione del DB.
    include $_SERVER['localhost'].'/includes/connect_DB.inc.php';

    //Creazione tabella per Amministratore
    include $_SERVER['localhost'].'/includes/create_admin_table.inc.php';

    if( isset($_POST['submit']) && $_POST['submit']== "Register")
    {

    if( $_POST['username'] != "" &&
    $_POST['password'] != "" &&
    $_POST['nome'] != "" &&
    $_POST['cognome'] != "" &&
    $_POST['email'] != ""
    )
    {
    $sql1="SELECT username FROM admin".
    "WHERE username='".$_POST['username']."';";

    $result=mysql_query($sql1) or die(mysql_error());

    if(mysql_num_rows($result) == 0)
    {
    $sql2 = "INSERT INTO admin(username, password,".
    "nome,cognome, email)".
    "VALUES('".$_POST['username']."',".
    "(PASSWORD('".$_POST['password']."')), '".
    $_POST['nome']."', '".$_POST['cognome'].
    "','".$_POST['email']."'";
    $result=mysql_query($sql2) or die (mysql_error());

    ?>



    Grazie, <?php echo $_POST['nome']."".
    $_POST['cognome']; ?> per la registrazione!

    <?php
    header("Refresh: 5; URL = main_ins.php");
    echo "La tua registrazione è stata completata!".
    "Verrai inviato alla pagina costruzione del gioco!
    ";
    echo"(Se il tuo browser non supporta questo,".
    "<a href=\"main_ins.php\">click here</a>)";
    die();

    }
    } else
    {
    ?>




    <font color="#FF0000">Non tutti i campi sono stati inseriti!</font>

    <form action="register.php" method="post">


    Reinserisci i tuoi dati mancanti:</p>

    Username: <input type="text" name="username"
    value="<?php echo $_POST['username']; ?>">


    Password: <input type="password" name="password"
    value="<?php echo $_POST['password']; ?>">

    Nome: <input type="text" name="nome"
    value="<?php echo $_POST['nome']; ?>">

    Cognome: <input type="text" name="cognome"
    value="<?php echo $_POST['cognome']; ?>">

    Email: <input type="text" name="email"
    value="<?php echo $_POST['email']; ?>">

    <input type="submit" name="submit" value="Register">
    <input type="reset" value="Clear">
    </form>
    </p>


    <?php
    }
    }else {
    ?>



    Benvenuto nella pagina di registrazione!

    Username, Password, Nome e Cognome sono necessari !
    <form action="register.php" method="post">
    Username: <input type="text" name="username">

    Password: <input type="password" name="password">

    Nome: <input type="text" name="nome">

    Cognome: <input type="text" name="cognome">

    Email: <input type="text" name="email" >

    <input type="submit" name="submit" value="Register">
    <input type="reset" value="Clear">
    </form>
    </p>

    <?php
    }
    ?>
    </body>
    </html>

  2. #2

    ......

    Ciao.
    $_SERVER['localhost']
    metti
    $_SERVER['HTTP_HOST']
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2006
    Messaggi
    108
    Ciao Wisher, ho fatto come mi hai suggerito,
    però ora non mi apre gli include, penso che l'errore sia nella INSERT.

    gli errori sono:
    Warning: Failed opening 'localhost/includes/connect_Mysql.inc.php' for inclusion (include_path='.;c:\php4\pear') in c:\programmi\apache group\apache\test\progetto\register.php on line 13

    Warning: Failed opening 'localhost/includes/create_DB.inc.php' for inclusion (include_path='.;c:\php4\pear') in c:\programmi\apache group\apache\test\progetto\register.php on line 16

    Warning: Failed opening 'localhost/includes/connect_DB.inc.php' for inclusion (include_path='.;c:\php4\pear') in c:\programmi\apache group\apache\test\progetto\register.php on line 19

    Warning: Failed opening 'localhost/includes/create_admin_table.inc.php' for inclusion (include_path='.;c:\php4\pear') in c:\programmi\apache group\apache\test\progetto\register.php on line 22

  4. #4

    .........

    Ciao.
    Per includere un file il percorso che usi è sbagliato
    non è localhost ma il percorso assoluto alla root o relativo
    Devi usare un percorso
    relativo tipo include/tuofile.php o uno assoluto
    con dirname(__FILE__)."/include/tuofile.php"
    per rederti conto di cosa fa fai un
    echo dirname(__FILE__);
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

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.