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

    Iscrizione con conferma email

    Salve a tutti del forum, spero possiate aiutarmi con questo problema, in pratica volevo creare uno script che permetta di registrarsi al sito web, ed accedere a certe pagine, solo dopo la conferma dell'email, per l'avvenuta registrazione...lo script utilizzato di divide in piu file, dunque...per il database utilizzo, phpmyadmin...ho creato, il database e le tabelle, con questi dati:

    install.php
    <?php
    include ("config.php");
    //creating tabe
    mysql_query("CREATE TABLE log_user (ID MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(60), password VARCHAR(60), email VARCHAR(60), account VARCHAR(60))");

    Print "<h3>Your table has been created<h3>";
    ?>



    Config.php

    <?php
    // Data of your Database
    $host = "localhost";
    $user = "user";
    $pass = "pass";
    $nome = "my_table";
    // Connection to Database
    mysql_connect("$host", "$user", "$pass") or die(mysql_error());
    mysql_select_db("$nome") or die(mysql_error());

    ?>





    Register.php


    <?php
    include ("config.php");

    //This code runs if the form has been submitted
    if (isset($_POST['submit'])) {

    //This makes sure they did not leave any fields blank
    if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] | !$_POST['mail'] ) {
    die('Completare TUTTI i campi, Grazie.');
    }

    // checks if the username is in use
    if (!get_magic_quotes_gpc()) {
    $_POST['username'] = addslashes($_POST['username']);
    }
    $usercheck = $_POST['username'];
    $check = mysql_query("SELECT username FROM log_user WHERE username = '$usercheck'")
    or die(mysql_error());
    $check2 = mysql_num_rows($check);

    //if the name exists it gives an error
    if ($check2 != 0) {
    die(" ATTENZIONE, L' username ".$_POST['username']." e' gia'* in uso ");
    }



    // checks if the mail is in use
    if (!get_magic_quotes_gpc()) {
    $_POST['mail'] = addslashes($_POST['mail']);
    }
    $mailcheck = $_POST['mail'];
    $check = mysql_query("SELECT email FROM log_user WHERE email = '$mailcheck'")
    or die(mysql_error());
    $mailcheck2 = mysql_num_rows($check);

    //if the name exists it gives an error
    if ($mailcheck2 != 0) {
    die("Attenzione, L' Email ".$_POST['mail']." e' gia' in uso.");
    }


    // checks if the mail correct.
    if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$_POST['mail'] )){
    die("Attenzione, L' Email ".$_POST['mail']." e' incorretta.");}





    // this makes sure both passwords entered match
    if ($_POST['pass'] != $_POST['pass2']) {
    die('Le password non corrispondono. ');
    }

    // here we encrypt the password and add slashes if needed
    $pass = $_POST['pass'];
    $_POST['pass'] = md5($_POST['pass']);
    if (!get_magic_quotes_gpc()) {
    $_POST['pass'] = addslashes($_POST['pass']);
    $_POST['username'] = addslashes($_POST['username']);
    }

    // now we insert it into the database
    $token = "testo a caso";
    $mailcr = md5($_POST['email'].$token);

    $insert = "INSERT INTO log_user (username, password, email, account)
    VALUES ('".$_POST['username']."', '".$_POST['pass']."', '".$_POST['mail']."', '".$mailcr."')";
    $add_member = mysql_query($insert);
    ?>


    <h1>Registrato con Successo!</h1>


    Grazie, si e' correttamente registrato, Confermi la registrazione con l' email che le e' stata inviata.</a>.</p>
    <?php

    }
    else
    {
    ?>


    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <table border="0">
    <tr><td>Username:</td><td>
    <input type="text" name="username" maxlength="60">
    </td></tr>
    <tr><td>Password:</td><td>
    <input type="password" name="pass" maxlength="10">
    </td></tr>
    <tr><td>Conferma Password:</td><td>
    <input type="password" name="pass2" maxlength="10">
    </td></tr>
    <tr><td>Email:</td><td>
    <input type="text" name="mail" maxlength="60">
    </td></tr>

    <tr><th colspan=2><input type="submit" name="submit" value="Registrati"></th></tr> </table>
    </form>

    <?php
    }
    ?>

    già qui il primo errore, ah per la creazione dei dati nel database non ho usato lo script, ma li ho fatti a mano, con quelle caratteristiche, e quando mi linko al file Register.php, ho il seguente errore : Access denied for user 'www-data'@'localhost' (using password: NO)

    i dati sono inseriti correttamente...ma non so...e questo il primo errore...andiamo per gradi

  2. #2
    posso postare il resto del codice se cè bisogno...perchè, veramente non capisco...

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