Home > Backend Development > PHP Tutorial > PHP user registration example code, suitable for beginners_PHP tutorial

PHP user registration example code, suitable for beginners_PHP tutorial

WBOY
Release: 2016-07-13 10:58:44
Original
868 people have browsed it

php tutorial user registration example code, suitable for beginners
if($_POST[submit]){

checkusername($_POST[username]);

if($_SESSION["code"]==$_POST[code])

{

$username= str_replace(" ","",$_POST[username]);
$password=md5($_POST[password].ALL_PS);
$sql="INSERT INTO `member`.`user_list` (`uid`, `m_id`, `username`, `password`) VALUES (NULL, '$_POST[select]', '$username','$password ' )";
Mysql tutorial_query($sql);
echo "Registration successful";
}

else
{
echo "Verification code error"."
";
Session_destroy();
}
}


function checkusername($username)
              {
               $sql2 = "select uid from user_list where username='".mysql_escape_string($username)."'";
                 $result = mysql_query($sql2) or die ('ERROR: '.mysql_error());
If(mysql_num_rows($result)>0)
                                                  {
echo "The username already exists, please change it!";

exit();
                 }
            else{
echo "<script> location.href='reg.php'</script>";
                 }


           }


?>

Username:

Password:

Position:




Verification code:





www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631994.htmlTechArticlephp tutorial user registration example code, suitable for beginners if($_POST[submit]){ checkusername($_POST[ username]); if($_SESSION[code]==$_POST[code]) { $username= str_replace( ,,$_POST[usern...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template