香港专业教育学院从事过登录脚本,似乎总是失败消息我的代码出了什么问题? [英] Ive worked on loginscript and seem to always fail message what is wrong in my code?

查看:133
本文介绍了香港专业教育学院从事过登录脚本,似乎总是失败消息我的代码出了什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的登录脚本
<?php
需要``database.php'';


if(!empty($ _ POST [''username'']))&&!empty($ _ POST [''password''])):

$ records = $ conn-> prepare("SELECT id,username,password from table2 WHERE username =``:username''");

$ records-> bindparam('':username'',$ _POST [''username'']);
$ records-> execute();
$ results = $ records-> fetch(PDO :: FETCH_ASSOC);


if(count($ results)> 0&& password_verify($ _ POST [''password''],$ results [''password''])){

die(成功");
标头:("login.php");

} else {die("dieees");
}
endif;
?>
<!Doctype html>

< meta charset ="utf-8">







我的注册脚本

My login script
<?php
require ''database.php'';


if(!empty($_POST[''username''] ) && !empty($_POST[''password''])):

$records= $conn->prepare("SELECT id,username,password FROM table2 WHERE username = '':username''");

$records->bindparam('':username'', $_POST[''username'']);
$records->execute();
$results = $records->fetch(PDO::FETCH_ASSOC);


if(count($results) > 0 && password_verify($_POST[''password''], $results[''password''])){

die( "sucess");
header:("login.php");

} else{ die("dieees");
}
endif;
?>
<!Doctype html>

<meta charset="utf-8">







my signup script

<?php
$server = ''localhost'';
$username= ''root'';
$password = '''';
$database = ''users'';
try{
	$conn = new PDO("mysql:host=$server;dbname=$database;", $username, $password);
} catch(PDOException $e){
	die("connection failed:" .$e->getmessage());
}

if(!empty($_POST["username"]) && !empty($_POST["password"])):


$sql = "INSERT INTO table2 (username, password) VALUES (:username, :password)";
$stmt = $conn->prepare($sql);
$stmt->bindParam('':username'',$_POST[''username'']);
$stmt->bindParam('':password'', password_hash($_POST[''password''], PASSWORD_BCRYPT) );

if( $stmt->execute() ):
header:("login.php");
else:
die(''fail'');
endif;	
endif;

?>
<html>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Supermercado+One" rel="stylesheet">

<body>
<h1> ReGiSTER</h1>
<form action="signup.php" method="POST">
<input type=text" placeholder="enter ur username" name="username">
<input type="password" placeholder=password name="password">
<input type="password" name="confirm_password">
<input type="submit">
</form>
</body>
</html>



我尝试过的事情:

这些天我尝试了不同的代码,但似乎我也需要放弃
总是出现错误消息,或者只是没有登录
但是,注册工作正常,但使用哈希密码在同一行上给出了错误.



What I have tried:

i have tried different codes these days but seem i need too give up
Always a error message or just plain not getting a login
but signup works pretty ok but giving a error on same line with hash password.

推荐答案

_POST [''username''])&& !empty(
_POST[''username''] ) && !empty(


_POST [''password'']))):

_POST[''password''])):


records =
records=


这篇关于香港专业教育学院从事过登录脚本,似乎总是失败消息我的代码出了什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆