Php 激活用户';通过邮寄他们的帐户

Php 激活用户';通过邮寄他们的帐户,php,Php,我不会使用rand()创建激活密钥。有可能两个人得到相同的号码 因此,我总是将SHA1()与用户名和当前时间一起使用 要自动删除未激活的帐户,请执行以下操作: 您可以创建一个cronjob,自动检查注册时间和当前时间之间的差异。检查: 说对了,cron,简单的linux程序用来执行调度操作,我个人用它来删除会话文件。如何使用cron <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR

我不会使用rand()创建激活密钥。有可能两个人得到相同的号码

因此,我总是将SHA1()与用户名和当前时间一起使用


要自动删除未激活的帐户,请执行以下操作:

您可以创建一个cronjob,自动检查注册时间和当前时间之间的差异。

检查:

说对了,cron,简单的linux程序用来执行调度操作,我个人用它来删除会话文件。如何使用cron

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<body>
<?php

require_once('database_detail.php');
if(isset($_POST['submit']))
{   
$dbc=mysqli_connect(cname,chost,cpwd,cdb);
$username=mysqli_real_escape_string($dbc,trim($_POST['username']));
$password=mysqli_real_escape_string($dbc,trim($_POST['password']));
$confirm=mysqli_real_escape_string($dbc,trim($_POST['confirm']));
$email=mysqli_real_escape_string($dbc,trim($_POST['email']));
$phone=mysqli_real_escape_string($dbc,trim($_POST['phone']));
    if(!empty($username) && !empty($password) && !empty($confirm) && !empty($email) &&        !empty($phone))
    {   
            if($password==$confirm)
            {
                $query="select * from user where      user_username='$username'";
                $data=mysqli_query($dbc,$query);
                if(mysqli_num_rows($data)== 0) 
                {
                    $random=rand(1000,10000);
                    $query="insert into     user(user_username,user_password,user_email,user_phone,date,random)".
                        "values('$username',SHA('$password'),'$email','$phone',now(),'$random')";
                    mysqli_query($dbc,$query);
                    $message="Account created successfully, kindly     visit the following link to activate your account"."\n"."localhost/login?    activation=".$random;
                    $to=$email;
                    $subject="Account Activation";
                        mail($to,$subject,$message,'From:'.'xyz@gmail.com');
                    echo 'Account created successfully. kindly visit     your email addres and activate your account.';
                exit();

                }
                else 
            {
                echo 'same username exists';
                $username="";
                }
            }
            else echo 'Enter the same password in both';
    }
    else echo 'Enter all the fields';
}
?> 

<fieldset>
<legend>signup</legend>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" >
Username:<input type="text" id="username" name="username"  />
Password:<input type="password" name="password" id="password" />
Email<input type="text" name="email" id="email" />
Contact number<input type="text" name="phone" id="phone" />
Confirm Password:<input type="password" name="confirm" id="confirm" />
</fieldset>
<input type="submit" name="submit" value="Sign up" />
</form>
</body>
</html>

SHA1()做什么??还有cronjob做什么,比如如何实现它?SHA1()从字符串创建哈希,请参阅。使用cronjob,脚本将在特定时间段之间自动调用。也许你的提供商提供了类似的服务,但也有许多其他的免费系统。@user603003我先用SHA保存了密码“abc”,然后用SHA1保存,但它仍然在我的数据库中保存了相同的内容。i、 实际上,在许多编程语言中,SHA只是SHA1的另一个(函数)名称。但是SHA只是SHA1、SHA2和其他一些的通用术语。
    Here is the format of a cron job file:

[min] [hour] [day of month] [month] [day of week] [program to be run]

where each field is defined as
[min]   Minutes that program should be executed on. 0-59. Do not set as * or the program will be run once a minute.
[hour]  Hour that program should be executed on. 0-23. * for every hour.
[day of month]  Day of the month that process should be executed on. 1-31. * for every day.
[month] Month that program whould be executed on. 1-12 * for every month.
[day of week]   Day of the week. 0-6 where Sunday = 0, Monday = 1, ...., Saturday = 6. * for every day of the week.
[program]   Program to be executed. Include full path information.

Here are some examples:

0,15,30,45 * * * * /usr/bin/foo

Will run /usr/bin/foo every 15 minutes on every hour, day-of-month, month, and day-of-week. In other words, it will run every 15 minutes for as long as the machine it running.