Problema con file di registrazione in php, non funziona e dà continui errori

PHPMan

Nuovo Utente
2 Feb 2015
17
2
0
PHP:
<?php


include("functions_custom.php");
include("register.php");
include("config.php");


$username = trim(stripslashes($_POST['username'])); // trim
$password = trim(stripslashes($_POST['password'])); // trim
$email = trim(stripslashes($_POST['email']));       // trim
$action = trim(stripslashes($_POST['action']));     // trim

if(isset($username) && isset($password) && isset($email)) {
      
      if(isset($action) && ($action=="Submit New Registration")) {

     $con = mysql_connect($host, $db_user, $db_psw);

                  mysql_select_db($db_name, $con);

$query = mysql_query("SELECT username FROM users WHERE username=".$username."");

if (! $query)

  {

      echo "<link href=\"css/custom_alert.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />
        <script src=\"//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js\"></script>
        <script src=\"js/custom_alert.js\"></script>
        <script type=text/javascript>_alert('Error!','Username already exists! Choose another')</script>";
  }


  $sql = mysql_query("SELECT email FROM users WHERE email=".$email."");

if (! $sql)

  {
      echo "<link href=\"css/custom_alert.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />
        <script src=\"//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js\"></script>
        <script src=\"js/custom_alert.js\"></script>
        <script type=text/javascript>_alert('Error!','Email already exists! Choose another')</script>";
  }
  

// Mail      
  
$to = $email;

$subject = "Confirm your registration";
$actioncode= generateRandomImpossibleTosolveString(10);
$activation_code= sha1(md5(sha1($actioncode)));
$urlencode_code = urlencode($activation_code);
$urlencode_username = urlencode($username);

$body = "

Hi ".$username.",

This is a email for confirming your registration at ".$website."

Please, for done it, go to following link:

http://".$website."/regverify.php?activationcode=".$urlencode_code."&username=".$urlencode_username."

You will must insert following credentials:

Username = ".$username.";
Confirm Code = ".$activation_code.";

Enjoy in our community!
 
";

$headers = "From: Confirm Your Registration!<regmodule@".$website.".it>";


if(@mail($to, $subject, $body, $headers)) { 

  echo "<link href=\"css/custom_alert.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />
        <script src=\"//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js\"></script>
        <script src=\"js/custom_alert.js\"></script>
        <script type=text/javascript>_alert('Success!','An email will be sended to your email address, check and follow instructions in it', 'index.php')</script>";

} else {

  echo "<link href=\"css/custom_alert.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />
        <script src=\"//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js\"></script>
        <script src=\"js/custom_alert.js\"></script>
        <script type=text/javascript>_alert('Error!','Impossible sending email to your email address!', 'register.php')</script>";

}

    if(isset($_GET['username']) && isset($_GET['activationcode']) && ($_GET['username'] == $username) && ($_GET['activationcode']) == $activation_code) {


$value = "true";
$urlencode_value = urlencode($value);

                
                echo "<html>
<head>
 
    <title>Confirm Module</title>
 
    <link href=\"css/access.css\" rel=\"stylesheet\" type=\"text/css\" />
</head>
<body>
 
    <form id=\"login\" action=\"regverify.php?activationcode=".$urlencode_code."&username=".$urlencode_username."&confirm=".$urlencode_value."\" method=\"post\">
        <fieldset id=\"inputs\">
            <input id=\"username\" name=\"usernameact\" type=\"text\" placeholder=\"Username\" autofocus required>
            <input id=\"password\" name=\"actcode\" type=\"password\" placeholder=\"Activation Code\" autofocus required>
        </fieldset>
        <fieldset id=\"actions\">
            <input type=\"submit\" id=\"submit\" name=\"action\" value=\"Send your confirm\">
        </fieldset>
    </form>
 </body>
</html>";


if(isset($_GET['confirm']) && ($_GET['confirm'] == $value) && isset($_GET['activationcode']) && ($_GET['activationcode'] == $activation_code)
&& isset($_GET['username']) && ($_GET['username'] == $username) && isset($_POST['unsernameact']) && ($_POST['usernameact'] == $username)
&& isset($_POST['actcode']) && ($_POST['actcode'] == $activation_code) && isset($_POST['action']) && ($_POST['action'] == "Send your confirm"))

{

$now = TIME_NOW;

          
                    
     $sql = mysql_query("ALTER TABLE users ADD activationcode varchar(120) AFTER email");
     $querysql = mysql_query("ALTER TABLE users ADD lastvisit int unsigned AFTER activationcode");
     $querymysql = mysql_query("ALTER TABLE users ADD lastactive int unsigned AFTER lastvisit");
     $sqlquery = mysql_query("ALTER TABLE users ADD memregdate int unsigned AFTER lastactive");

include("functions_custom.php");

           $salt= generateRandomImpossibleTosolveString(100);
           $saltedpsw= sha1(md5($salt.sha1($password)));
           $now = TIME_NOW;

     $query = mysql_query("INSERT INTO users (username, password, email, activationcode, lastvisit, lastactive, memregdate) VALUES ($username, $password, $email, $activation_code, $now, $now, $now)");

     while($done = mysql_fetch_array($query)) {

            
             $user = array(

             "username" => $username,
             "password" => $saltedpsw,
             "email"    => $mail,
             "activationcode" => $activation_code,
             "lastvisit" =>  $now,
             "lastactive" => $now,
             "memregdate" => $now

            );


       echo "<link href=\"css/custom_alert.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />
        <script src=\"//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js\"></script>
        <script src=\"js/custom_alert.js\"></script>
        <script type=text/javascript>_alert('Success!','Congratulations! You have confirm successfully your reg request, now you can connect to forum!', 'index.php')</script>";


     }


}

    }


      }

}

?>

C'è un problema con il file regverify.php Ciò che vorrei fare è registrarsi, controllare se l'username o l'email immessa già esiste, se esiste faccio apparire un alert personalizzato. Senno invio la mail con il codice di conferma e faccio apparire un html per confermare la registrazione cliccando sul link, se sarà confermato sarà inserito tutto nel database, ma non funziona un cazzo.

http://hydrerscript.altervista.org/register.php <--- Provare per credere


Aiutatemi!
 
Discussioni simili
Autore Titolo Forum Risposte Data
L problema collegamento file css con html HTML e CSS 1
E Problema accesso a file con app sviluppata con MIT APP INVENTOR 2 Sviluppo app per Android 0
C [PHP] Problema con download file PHP 0
Giacomo Boccherini Problema trasferimento file con FileZilla Windows e Software 10
O Problema con vettorizzazione da file png Webdesign e Grafica 1
L [PHP] problema parsing con comando file get contents PHP 7
P Problema con file inclusi PHP 1
C Problema con update di un file PHP 6
M Problema con l'importazione file csv PHP 3
M Problema con date importate da file txt PHP 13
R Problema con la creazione file PHP 2
M Problema con importa file CSV e Linus PHP 0
D Problema collegamento file css con html HTML e CSS 4
F Problema con upload di file PHP 1
asevenx Problema Dreamweaver "impossibile individuare i file correlati dinamicamente..." e con i <div> HTML e CSS 1
F Problema con selezione di un file nel database PHP 5
C Problema nel Caricare file e spostarlo con la funzione move_uploaded_file PHP 14
M Problema in Internet Explorer 7 (ma anche 6 o 8 ) con i file pdf Windows e Software 2
M Problema con dimensione file PHP 2
J problema con apache2+php ed invio file con cURL Apache 2
J Problema invio file con cURL php su server verso server PHP 1
T java-problema con i file wav Java 0
J Problema con file .xls con impaginamento tabella PHP 0
M Problema con la visualizzazione file presente in db PHP 2
Z Help Problema con file config.php PHP 3
emanuelevt problema con file -> \n PHP 2
A photoshop cs3 problema con file png Photoshop 8
F Problema Upload file con Internet Explorer PHP 29
E Problema con la lettura di un file di testo Classic ASP 3
F problema con la modifica del testo di un file PHP 1
R problema con file audio HTML e CSS 6
A problema con Import File text Database 0
G problema con file .htaccess PHP 5
N problema con file flv Flash 0
G Problema con file .swf Flash 8
O problema con dvr dahua xvr5116 IP Cam e Videosorveglianza 0
G Problema con Xampp Web Server 1
andrea barletta Problema con miniature comandi Photoshop 0
I problema con alice Posta Elettronica 0
N Problema con position absolute e overflow HTML e CSS 4
L Problema con inner join PHP 11
K [php] Problema con inner join PHP 4
K [PHP] Problema con variabili concatenate. PHP 1
O problema con query PHP 4
I problema con 2 account Posta Elettronica 1
M Problema con Try Catch PHP 0
Sergio Unia Problema con gli eventi del mouse su una data table: Javascript 2
T PROBLEMA CON SESSIONI PHP 3
T ALTRO PROBLEMA CON ARRAY PHP PHP 1
R problema con else PHP 0

Discussioni simili