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

    errore pagina con inserisci record

    ho un sito in http://www.italianghosts.altervista.org
    ho un database mysql ( li è tutto a posto )
    la connessione "l" funziona.
    ho in questo sito una pagina: http://www.italianghosts.altervista.org/register il cui codice è

    <?php require_once('../../Connections/l.php'); ?>
    <?php
    // *** Redirect if username exists
    $MM_flag="MM_insert";
    if (isset($_POST[$MM_flag])) {
    $MM_dupKeyRedirect="h";
    $loginUsername = $_POST['username'];
    $LoginRS__query = "SELECT username FROM dl_user WHERE username='" . $loginUsername . "'";
    mysql_select_db($database_l, $l);
    $LoginRS=mysql_query($LoginRS__query, $l) or die(mysql_error());
    $loginFoundUser = mysql_num_rows($LoginRS);

    //if there is a row in the database, the username was found - can not add the requested username
    if($loginFoundUser){
    $MM_qsChar = "?";
    //append the username to the redirect page
    if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
    $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
    header ("Location: $MM_dupKeyRedirect");
    exit;
    }
    }

    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
    return $theValue;
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
    $insertSQL = sprintf("INSERT INTO dl_user (id, username, nome, cognome, password, mail, actived, `data`, sito_web, auth) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['id'], "int"),
    GetSQLValueString($_POST['username'], "text"),
    GetSQLValueString($_POST['nome'], "text"),
    GetSQLValueString($_POST['cognome'], "text"),
    GetSQLValueString($_POST['password'], "text"),
    GetSQLValueString($_POST['mail'], "text"),
    GetSQLValueString($_POST['actived'], "int"),
    GetSQLValueString($_POST['data'], "text"),
    GetSQLValueString($_POST['sito_web'], "text"),
    GetSQLValueString($_POST['auth'], "text"));

    mysql_select_db($database_l, $l);
    $Result1 = mysql_query($insertSQL, $l) or die(mysql_error());

    $insertGoTo = "h";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
    }

    mysql_select_db($database_l, $l);
    $query_Recordset1 = "SELECT * FROM dl_user";
    $Recordset1 = mysql_query($query_Recordset1, $l) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Documento senza titolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="20"></td>
    <td align="center" width="100">Home</td>
    <td width="20"></td>
    <td align="center" width="100">Registrati</td>
    <td width="20"></td>
    <td width="100" align="center" bgcolor="#999999">Registrati</td>
    <td width="20"></td>
    </tr>
    <tr>
    <td height="1" colspan="10" bgcolor="#CCCCCC"><table height="1" width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td> </td>
    </tr>
    </table></td>
    </tr>
    </table>
    <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
    Registrati
    <table align="center">
    <tr valign="baseline">
    <td nowrap align="right">Username:</td>
    <td><input type="text" name="username" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Nome:</td>
    <td><input type="text" name="nome" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Cognome:</td>
    <td><input type="text" name="cognome" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Password:</td>
    <td><input type="password" name="password" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Mail:</td>
    <td><input type="text" name="mail" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right"></td>
    <td><input name="submit" type="submit" value="Registrati"></td>
    </tr>
    </table>
    <input type="hidden" name="MM_insert" value="form1">
    </form>


    </p>


    </p>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    ?>
    ho inserito con macromedia dreamweaver mx 2004 un campo per inserire record nel database però quando tento di aprire la pagina mi dice:
    Fatal error: main() [function.require]: Failed opening required '../../Connections/l.php' (include_path='.:') in /membri/italianghosts/registrati/index.php on line 1
    è da una settimana che ci lavoro e non riesco a capire il perchè.ù
    AIUTOOOOO

  2. #2

  3. #3
    grazie ho risolto adesso però prova a registrarti
    a me da un erore:
    Column 'username' cannot be null
    anche se nel campo username è pscrivi qualcosa

  4. #4
    Utente di HTML.it L'avatar di kodode
    Registrato dal
    Sep 2002
    Messaggi
    1,896
    dovresti postare la parte di codice dove fai l'inserimento...
    dove dà questa errore?

  5. #5
    nella pagina di registrazione: http://www.italianghosts.altervista....nction.require

    il codice è:
    <?php require_once('../..//Connections/l.php'); ?>
    <?php require_once('../../Connections/l.php'); ?>
    <?php
    // *** Redirect if username exists
    $MM_flag="MM_insert";
    if (isset($_POST[$MM_flag])) {
    $MM_dupKeyRedirect="../..//register/function.require/h";
    $loginUsername = $_POST['username'];
    $LoginRS__query = "SELECT username FROM dl_user WHERE username='" . $loginUsername . "'";
    mysql_select_db($database_l, $l);
    $LoginRS=mysql_query($LoginRS__query, $l) or die(mysql_error());
    $loginFoundUser = mysql_num_rows($LoginRS);

    //if there is a row in the database, the username was found - can not add the requested username
    if($loginFoundUser){
    $MM_qsChar = "?";
    //append the username to the redirect page
    if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
    $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
    header ("Location: $MM_dupKeyRedirect");
    exit;
    }
    }

    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
    return $theValue;
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
    $insertSQL = sprintf("INSERT INTO dl_user (id, username, nome, cognome, password, mail, actived, `data`, sito_web, auth) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['id'], "int"),
    GetSQLValueString($_POST['username'], "text"),
    GetSQLValueString($_POST['nome'], "text"),
    GetSQLValueString($_POST['cognome'], "text"),
    GetSQLValueString($_POST['password'], "text"),
    GetSQLValueString($_POST['mail'], "text"),
    GetSQLValueString($_POST['actived'], "int"),
    GetSQLValueString($_POST['data'], "text"),
    GetSQLValueString($_POST['sito_web'], "text"),
    GetSQLValueString($_POST['auth'], "text"));

    mysql_select_db($database_l, $l);
    $Result1 = mysql_query($insertSQL, $l) or die(mysql_error());

    $insertGoTo = "../..//register/function.require/h";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
    $insertSQL = sprintf("INSERT INTO dl_user (username, nome, cognome, password, mail) VALUES (%s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['username'], "text"),
    GetSQLValueString($_POST['nome'], "text"),
    GetSQLValueString($_POST['cognome'], "text"),
    GetSQLValueString($_POST['password'], "text"),
    GetSQLValueString($_POST['mail'], "text"));

    mysql_select_db($database_l, $l);
    $Result1 = mysql_query($insertSQL, $l) or die(mysql_error());

    $insertGoTo = ".";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
    $insertSQL = sprintf("INSERT INTO user (Username, Password, Nome, Cognome, Mail) VALUES (%s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['Username'], "text"),
    GetSQLValueString($_POST['Password'], "text"),
    GetSQLValueString($_POST['Nome'], "text"),
    GetSQLValueString($_POST['Cognome'], "text"),
    GetSQLValueString($_POST['Mail'], "text"));

    mysql_select_db($database_l, $l);
    $Result1 = mysql_query($insertSQL, $l) or die(mysql_error());

    $insertGoTo = "a";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
    $insertSQL = sprintf("INSERT INTO user (Username, Password, Nome, Cognome, Mail) VALUES (%s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['Username'], "text"),
    GetSQLValueString($_POST['Password'], "text"),
    GetSQLValueString($_POST['Nome'], "text"),
    GetSQLValueString($_POST['Cognome'], "text"),
    GetSQLValueString($_POST['Mail'], "text"));

    mysql_select_db($database_l, $l);
    $Result1 = mysql_query($insertSQL, $l) or die(mysql_error());
    }

    mysql_select_db($database_l, $l);
    $query_Recordset2 = "SELECT * FROM `user`";
    $Recordset2 = mysql_query($query_Recordset2, $l) or die(mysql_error());
    $row_Recordset2 = mysql_fetch_assoc($Recordset2);
    $totalRows_Recordset2 = mysql_num_rows($Recordset2);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Registrati</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    body {
    background: url(../AOE3_logo.jpg);
    }
    </style>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_reloadPage(init) { //reloads the window if Nav4 resized
    if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
    else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true);
    //-->
    </script>
    </head>

    <body>
    <div id="Layer1" style="position:absolute; left:172px; top:88px; width:276px; height:166px; z-index:1"></div>
    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="20"></td>
    <td align="center" width="100">Home</td>
    <td width="20"></td>
    <td align="center" width="100">Login</td>
    <td width="20"></td>
    <td width="100" align="center" bgcolor="#999999">Registrati</td>
    <td width="20"></td>
    </tr>
    <tr>
    <td height="1" colspan="10" bgcolor="#CCCCCC"><table height="1" width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td> </td>
    </tr>
    </table></td>
    </tr>
    </table>



    </p>


    <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
    <table align="center">
    <tr valign="baseline">
    <td nowrap align="right">Username:</td>
    <td><input type="text" name="Username" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Password:</td>
    <td><input type="text" name="Password" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Nome:</td>
    <td><input type="text" name="Nome" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Cognome:</td>
    <td><input type="text" name="Cognome" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Mail:</td>
    <td><input type="text" name="Mail" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right"></td>
    <td><input type="submit" value="Registtrati"></td>
    </tr>
    </table>
    <input type="hidden" name="MM_insert" value="form1">
    </form>


    </p>


    </p>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset2);
    ?>
    già che ci sei spiegami anche una cosa: se metto questa pagina in: http://www.italianghosts.altervista....ster/index.php non funziona e mi dice:
    Fatal error: main() [function.require]: Failed opening required '../../Connections/l.php' (include_path='.:') in /membri/italianghosts/registrati/index.php on line 1
    invece: http://www.italianghosts.altervista....uire/index.php funziona a parte questo errore:
    Column 'username' cannot be null
    anche se nel campo username scrivi qualcosa

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.