id& Password Verification program implemented with PHP&JS

Source: Internet
Author: User

Statement: This procedure is purely my whim in the learning process, did not consider any feasibility, practicality, just stay for later reference.

Front Page

Sign.html

<!DOCTYPE HTML><HTML>    <Head>        <MetaCharSet= ' Utf-8 '>        <title>QQ Registration & Login</title>        <Linkrel= ' stylesheet 'type= ' Text/css 'href= './sign.css '>        <Scriptsrc= "Http://cdn.bootcss.com/blueimp-md5/1.1.0/js/md5.js"></Script>        <Scriptsrc= './sign.js 'type= ' Text/javascript '> </Script>     </Head>    <Body>        <Divclass= ' header '>QQ Registration & Login</Div>        <Divclass= ' container '>        <H3>Registered</H3>        <formname= ' Signup 'Action= './signup.php 'onsubmit= ' return 'ValidateForm1 () ' Method= ' Post '>QQ:<inputtype= ' text 'name= ' uid 'ID= ' Userid1 '>Password:<inputtype= ' Password 'name= ' upd 'ID= ' Userpassword1 '>            <inputtype= ' Submit 'onsubmit=""value= ' Register '>        </form>        <H3>Login</H3>        <formname= ' signin 'Action= './signin.php 'onsubmit= ' return 'ValidateForm2 (); ' Method= ' Post '>QQ:<inputtype= ' text 'name= ' uid 'ID= ' Userid2 '>Password:<inputtype= ' Password 'name= ' upd 'ID= ' Userpassword2 '>            <inputtype= ' Submit 'onsubmit=""value= ' Login '>        </form>        </Div>    </Body></HTML>

Css

Sign.css

* {margin:0 0 0 0;padding:0 0 0 0;}Body{background:WhiteSmoke;font-size:1em;}. Header{Height:3em;font-size:2.5em;Line-height:3em;Color:Gray;Border-bottom:solid black 1px;text-align:Center;}. Container{text-align:Center;}

Js

Sign.js

functionValidateForm1 () {varID = This[' Userid1 '].value; varPassword = This[' Userpassword1 '].value; if(!id.match (/^\d{5,10}$/) {alert (' ID must be 5 to 10 digits '); return false; }    if(!password.match (/^[\d\w]{6,18}$/) {alert (' Password must be 6 to 32 digits and/or letters '); return false; }     This[' userpassword1 '].value =MD5 (password);}functionValidateForm2 () {varID = This[' Userid2 '].value; varPassword = This[' Userpassword2 '].value; if(!id.match (/^\d{5,10}$/) {alert (' ID must be 5 to 10 digits '); return false; }    if(!password.match (/^[\d\w]{6,18}$/) {alert (' Password must be 6 to 18 digits and/or letters '); return false; }     This[' userpassword2 '].value =MD5 (password);}

Server-side scripting

signin.php

<?PHP$uid=$_post[' UID '];$upd=$_post[' Upd '];$upd=MD5($upd);$conn=Mysqli_connect(' localhost ', ' myqq ', ' myqq ', ' QQ ');if(!$conn){     die("Database connection failed.")Mysqli_connect_error());}$sql _select= <<<eofselect ID, password from user where id = ' $uid 'EOF;$result=$conn->query ($sql _select);if($result->num_rows = = 1){    //echo ' user presence ';    $dbupd= ($result-&GT;FETCH_ASSOC ()) [' Password ']; if($dbupd==$upd ){        Echo"Login Successful"; }    Else {        Echo"Bad password"; //echo "<br>". $upd. "<br>". $DBUPD;    }    }Else {    Echo"User does not exist";}?>

signup.php

<?PHP$uid=$_post[' UID '];$upd=$_post[' Upd '];$upd=MD5($upd);//Echo $upd. ' <br> ';//echo $uid. $UPD;$conn=Mysqli_connect(' localhost ', ' myqq ', ' myqq ', ' QQ ' );if(!$conn){     die("Database connection failed.")Mysqli_connect_error() );} $sql _select= <<<eofselect ID, password from user where id = ' $uid 'EOF;//echo $sql _select;$result=$conn->query ($sql _select ) ;if($result->num_rows <= 0){    $sql _insert= <<<Eofinsert into user values ($uid, ' $UPD ') EOF; if($conn->query ($sql _insert) ===TRUE )    {        Echo' Registered success '; }    Else {        Echo"Registration failed, please try again".$sql. ' <br> '.$conn-error; }}Else {    Echo"User already exists";}$conn-close ();?>

id& Password Verification program implemented with PHP&JS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.