我正在为我的网站开发登录系统,但是当我将所有信息(用户,密码,电子邮件)插入到sigm-up函数的数据库中时,它将所有变量设置为0.我知道这不是传递变量的问题,因为我已经回应了用户名和密码,他们就是他们想要的。我的注册页面的代码如下:
<?php
include '../includes/conn.php';
include 'salt.php';
if($_POST['signup']){
$user = $_POST['user'];
$pass = $_POST['pass'];
$cpass = $_POST['cpass'];
$email = $_POST['email'];
if($pass == $cpass){
$hpass = create_hash($pass);
$query = $conn->prepare("INSERT INTO Users (Name, Password, Email) VALUES (?, ?, ?)");
$query->bind_param('sss', $user, $hpass, $email);
$query->execute();
if($query){
$msg = 'Account created successfully, please check your email to verify it.';
}else{
$msg = 'There was an error creating your account: ' . $conn->error . ', please try again later';
}
//echo $user . ' ' . $pass . ' ' . $hpass . ' ' . $email;
}else{
$msg = 'Passwords do not match.';
}
}
?>
<html>
<head>
<title>DiscFire Softworks - Login test</title>
<link rel="stylesheet" type="text/css" href="../includes/ie-styles.css">
<style type="text/css">
@import url('../includes/styles.css');
</style>
</head>
<body>
<div class="body">
<img src="../images/header.jpg" />
<div class="navbar">
<?php
$query = $conn->prepare("SELECT Name FROM pages ORDER BY ID asc");
$query->execute();
$query->bind_result($name);
while($query->fetch())
{
echo '<a href="/?page=' . $name . '">' . $name . '</a>';
}
?>
</div>
<?php
echo '<p>' . $msg . '</p>';
?>
<form method="POST" action="index.php" id="sign-up">
<input type="hidden" name="signup" value="1"/>
<label for="user">Username: </label>
<input type="text" style="width: 30%; margin-left: 59px;" name="user"></textarea>
<br />
<label for="pass">Password: </label>
<input type="password" style="width: 30%; margin-left: 60px;" name="pass"></textarea>
<br />
<label for="cpass">Confirm Password: </label>
<input type="password" style="width: 30%; margin-left: 1px;" name="cpass"></textarea>
<br />
<label for="user">Email: </label>
<input type="text" style="width: 30%; margin-left: 90px;" name="email"></textarea>
<input type="submit" />
</form>
</div>
</body>
</html>
以下是@Prix要求的SQL结构:
提前致谢!
答案 0 :(得分:-1)
似乎我将行设置为整数...哎呀。