赞
踩
链接:油管视频
下载MAMP之后,在web server的文件夹路径中加入配置文件:
<?php $con = mysqli_connect('localhost','root','root','unitycpr'); //check that connection happened if(mysqli_connect_errno()) { echo "1: Connection failed"; exit(); } $username = $_POST["name"]; $password = $_POST["password"]; //check if name exits $namecheckquery = "SELECT username, salt,hash,score FROM players WHERE username='" . $username . "';"; $namecheck = mysqli_query($con,$namecheckquery) or die("2: Name check query failed"); if(mysqli_num_rows($namecheck) != 1) { echo "5: Either no user with name, or more than one"; exit(); } $existinginfo = mysqli_fetch_assoc($namecheck); $salt = $existinginfo["salt"]; $hash = $existinginfo["hash"]; $loginhash = crypt($password, $salt); if($hash != $loginhash) { echo "6: Incorrect password"; exit(); } echo "0\t" . $existinginfo["score"]; ?>
<?php $con = mysqli_connect('localhost','root','root','unitycpr'); //check that connection happened if(mysqli_connect_error()) { echo "1: Connection failed"; exit(); } $username = $_POST["name"]; $password = $_POST["password"]; //check if name exits $namecheckquery = "SELECT username FROM players WHERE username='" . $username . "';"; $namecheck = mysqli_query($con,$namecheckquery) or die("2: Name check query failed"); if(mysqli_num_rows($namecheck)>0) { echo "3: Name already exists"; exit(); } //add user to the table $salt = "\$5\$rounds=5000\$" . "steamedhams" . $username . "\$"; $hash = crypt($password, $salt); $insertuserquery = "INSERT INTO players (username, hash, salt) VALUES ('" . $username . "' , '" . $hash . "','" . $salt . "');"; mysqli_query($con,$insertuserquery) or die("4: Insert player query failed");// error but don't know why echo("0"); ?>
<?php $con = mysqli_connect('localhost','root','root','unitycpr'); //check that connection happened if(mysqli_connect_errno()) { echo "1: Connection failed"; exit(); } $username = $_POST["name"]; $newscore = $_POST["score"]; //double check only one $namecheckquery = "SELECT username FROM players WHERE username='" . $username . "';"; $namecheck = mysqli_query($con, $namecheckquery) or die("2: Name check query failed"); if(mysqli_num_rows($namecheck) != 1) { echo "5: Either no user with name, or more than one"; exit(); } $updatequery = "UPDATE players SET score = " . $newscore . " WHERE username = '" . $username . "';"; mysqli_query($con,$updatequery) or die("7: Save query failed."); echo "0"; ?>
<?php
echo "123" . "\t" . 500;
?>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。