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

    Ciao chiedo aiuto per questo codice PHP!!!

    Ciao è da tanto che ormai porovo a sistemare quesot codice php per cambiare la password agli utenti del sito al mio amico!!! Il codice è questo che ho scritto nella pagina changepass.php!!!


    <?php

    /**in questa parte dello script creaiamo tre variabili $lo $pa $npd*/
    /**ognuna attesta la correttezza della procedura*/

    if (isset($_POST['submit']))
    {
    require_once ('databaseconnectinfo.php');

    /**funzione per filtrare i dati da inserire*/
    function escape_data ($data)
    {
    global $dbc;
    if (ini_get('magic_quotes_gpc'))
    {
    $data = stripslashes($data);
    }
    return mysql_real_escape_string($data, $dbc);
    }

    $message = NULL;

    /**verifichiamo l'esistenza del loginName altrimenti $lo è FALSE*/

    if (empty($_POST['loginName']))
    {
    $lo = FALSE;
    $message .= '

    You forgot to enter your Login Name!</p>';
    }
    else
    {
    $lo = escape_data($_POST['loginName']);
    }

    /**verifichiamo l'esistenza della password (vecchia password) altrimenti $pa è FALSE*/

    if (empty($_POST['password']))
    {
    $pa = FALSE;
    $message .= '

    You forgot to enter your existing password!</p>';
    }
    else
    {
    $pa = escape_data($_POST['password']);
    }

    /**verifichiamo l'esistenza del password1 (nuova password) altrimenti $nps è FALSE*/
    /**verifichiamo che password1 coincide con password2 (conferma password) altrimenti $nps è FALSE*/

    if (empty($_POST['password1']))
    {
    $npa = FALSE;
    $message .= '

    You forgot to enter your new password!</p>';
    }
    else
    {
    if ($_POST['password1'] == $_POST['password2'])
    {
    $npa = escape_data($_POST['password1']);
    }
    else
    {
    $npa = FALSE;
    $message .= '

    Your new password did not match the confirmed new password!</p>';
    }
    }

    /**se tutte e tre le variabili sono ok facciamo la query*/
    /**individuiamo l'id del record da modificare*/
    /**se è ==1 facciamo la query di update*/

    if ($lo && $pa && $npa)
    {
    $query = "SELECT id FROM tablename WHERE (loginName='$lo' AND password=PASSWORD('$pa') )";
    $result = @mysql_query ($query);
    $num = mysql_num_rows ($result);
    if ($num == 1)
    {
    $row = mysql_fetch_array($result, MYSQL_NUM);
    $query = "UPDATE tablename SET password=PASSWORD('$npa') WHERE id=$row[0]";
    $result = @mysql_query ($query);
    if (mysql_affected_rows() == 1)
    {
    echo '

    Your password has been changed.</p>';
    exit();
    }
    else
    {
    $message = '

    Your password could not be changed due to a system error. We apologize for any inconvenience.</p>

    ' . mysql_error() . '</p>';
    }
    }
    else
    {
    $message = '

    Your loginName and password do not match our records.</p>';
    }
    mysql_close();
    }
    else
    {
    $message .= '

    Please try again.</p>';
    }

    }

    /**stampa del messaggio risultante dalla procedura*/
    if (isset($message))
    {
    echo '<font color="red">', $message, '</font>';
    }
    ?>





    e da questi errori tra cui in rosso scrive Pleae Try Again, invece deve cambiare password!!!

    Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in D:\Inetpub\webs\feelmeit\databaseconnectinfo.php on line 18

    Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in D:\Inetpub\webs\feelmeit\databaseconnectinfo.php on line 18

    Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in D:\Inetpub\webs\feelmeit\databaseconnectinfo.php on line 18

    Please try again.

    Fatal error: Cannot redeclare escape_data() (previously declared in D:\Inetpub\webs\feelmeit\databaseconnectinfo.php:1 1) in D:\Inetpub\webs\feelmeit\changepass.php on line 89

    Il form è questo e si trova nella pagina manageme.php!!!

    <form action="changepass.php"act=true" method="post">
    <table cellpadding="2" cellpacing="2 border="0">
    <tr>
    <td><h2><font face="Times New Roman" color="green">[b]<div align="center">Change Your Password</div></font></h2></td>
    </tr>
    <tr>
    <td><font face="Times New Roman" color="green">Login Name:</td>
    <td>
    <input type="text" value="" name="loginName" /><?php if (isset($_POST['loginName'])) echo $_POST['loginName'];?></tr></td>
    <tr>
    <td>
    <font face="Times New Roman" color="green">Current Password:</td>
    <td>
    <input type="password" value="" name="password" /></tr></td>
    <tr>
    <td>
    <font face="Times New Roman" color="green">New Password:</td>
    <td><input type="password" value="" name="password1" /></tr></td>
    <tr>
    <td>
    <font face="Times New Roman" color="green">Confirm New Password:</td>
    <td><input type="password" value="" name="password2" /></td></tr>

    </fieldset>
    <tr>
    <td>
    <input type="submit" name="submit" value="changeme" /></tr></td>

  2. #2
    Utente di HTML.it L'avatar di telegio
    Registrato dal
    Sep 2001
    Messaggi
    2,592
    ti UPPO, e non so aiutarti oltre
    dagli errori manca il codice della pagina databaseconnectinfo.php
    poi continui a mettere la form così
    Codice PHP:
    <form action="changepass.php"act=true" method="post"> 
    usa questo.
    <form name="myform" method="POST" action="changepass.php">

  3. #3
    Il titolo della discussione non rispetta il regolamento

    http://forum.html.it/forum/showthrea...hreadid=412253
    Addio Aldo, amico mio... [03/12/70 - 16/08/03]

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.