php - Email with activation -
i'm trying make form login , registration in php website. users can register administration approval. in php send email admin activation code, code didn't work want. in users table have 2 rows (ativo,code)
register.php
require ("ligacaobd.php"); $user=$_post['user']; $pass=md5($_post['pass']); $email=$_post['email']; if($user && $email && $pass) { $confirmcode=rand(); $query=mysql_query("select * utilizadores user='".$user."'"); $numrows=mysql_num_rows($query); if($numrows==0) { $sql="insert utilizadores(id_user,id_type,user,email,password,ativo,code) values(null,'2','$user','$email','$pass','0','$confirmcode')"; $result=mysql_query($sql); if($result) { echo "thanks! please wait adminstration approval!"; } else { echo "failure!"; } } else { echo "that username exists! please try again another."; } $search="select * utilizadores id_type='1'"; $result=mysql_query($search); // while($row=mysql_fetch_assoc($result)) { $subject='new account request'; $from='... <...@gmail.com>'; $emailadmin=$row["email"]; $confirmurl= 'http://.../php/confirm.php?user=$user&code=$confirmcode'; $message=" new account has been requested following details: username: $user email: $email confirmation required. please click link below confirm registration: $confirmurl thanks"; mail($emailadmin, $subject, $message, 'from: ' .$from); }
and
confirm.php
$user=$_get['user']; $code=$_get['code']; $query=mysql_query("select * utilizadores 'user'='$user'"); while($row=mysql_fetch_assoc($query)) { $db_code=$row['confirmcode']; } if($code==$db_code) { mysql_query("update utilizadores set 'ativo'='1'"); mysql_query("update utilizadores set 'code'='0'"); echo "thanks. email has been registered"; } else { echo "username , code don't match!"; }
error: "username , code don't match!"
can me?
Comments
Post a Comment