注册表格不工作和存储数据在数据库(PHP/MYSQL)
Registration form not working and storing data in Database(PHP/MYSQL)
我试图用PHP/MySQL构建一个注册页面,第一次当我试图注册为新用户时,它工作得很好。过了一段时间,我再次检查注册,该页面没有处理数据到数据库。注册页面信息的代码如下请帮帮我吧
<?php
require_once("models/config.php");
if(isUserLoggedIn()) { header("Location: index.php"); die(); }
?>
<?php
//Forms posted
if(!empty($_POST))
{
$errors = array();
$email = trim($_POST["email"]);
$username = trim($_POST["username"]);
$password = trim($_POST["password"]);
$confirm_pass = trim($_POST["passwordc"]);
//Perform some validation
//Feel free to edit / change as required
if(minMaxRange(5,25,$username))
{
$errors[] = lang("ACCOUNT_USER_CHAR_LIMIT",array(5,25));
}
if(minMaxRange(8,50,$password) && minMaxRange(8,50,$confirm_pass))
{
$errors[] = lang("ACCOUNT_PASS_CHAR_LIMIT",array(8,50));
}
else if($password != $confirm_pass)
{
$errors[] = lang("ACCOUNT_PASS_MISMATCH");
}
if(!isValidemail($email))
{
$errors[] = lang("ACCOUNT_INVALID_EMAIL");
}
//End data validation
if(count($errors) == 0)
{
//Construct a user object
$user = new User($username,$password,$email);
//Checking this flag tells us whether there were any errors such as possible data duplication occured
if(!$user->status)
{
if($user->username_taken) $errors[] = lang("ACCOUNT_USERNAME_IN_USE",array($username));
if($user->email_taken) $errors[] = lang("ACCOUNT_EMAIL_IN_USE",array($email));
}
else
{
//Attempt to add the user to the database, carry out finishing tasks like emailing the user (if required)
if(!$user->userPieAddUser())
{
if($user->mail_failure) $errors[] = lang("MAIL_ERROR");
if($user->sql_failure) $errors[] = lang("SQL_ERROR");
}
}
}
if(count($errors) == 0)
{
if($emailActivation)
{
$message = lang("ACCOUNT_REGISTRATION_COMPLETE_TYPE2");
}
else {
$message = lang("ACCOUNT_REGISTRATION_COMPLETE_TYPE1");
}
}
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registration | <?php echo $websiteName; ?> </title>
<?php require_once("head_inc.php"); ?>
</head>
<body>
<div class="modal-ish">
<div class="modal-header">
<h2>Sign Up</h2>
</div>
<div class="modal-body">
<div id="success">
<p><?php echo $message ?></p>
</div>
<div id="regbox">
<form name="newUser" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<p>
<label>Username:</label>
<input type="text" name="username" />
</p>
<p>
<label>Password:</label>
<input type="password" name="password" />
</p>
<p>
<label>Re-type Password:</label>
<input type="password" name="password" />
</p>
<p>
<label>Email:</label>
<input type="text" name="email" />
</p>
</div>
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-primary" name="new" id="newfeedform" value="Register" />
</div>
</form>
</div>
<div class="clear"></div>
<p style="margin-top:30px; text-align:center;">
<a href="login.php">Login</a> / <a href="forgot-password.php">Forgot Password?</a> / <a href="<?php echo $websiteUrl; ?>">Home Page</a>
</p>
</body>
</html>
也检查你的连接页面。将这些类型的查询添加到您的注册页面..
mysql_query("insert into <your_table>(email,username,password) values('$email',' $username',' $password')");
MySQL代码到底在哪里?你已经检查了数据,但这就是它所做的。它没有被发送到数据库。
相关文章:
- 如何通过php页面将数据库值检索到jquery自动完成框中
- PHP:显示sqlite数据库中的html格式数据,使用tinymce保存
- 将地理编码结果转换为php变量以发布到mysql数据库
- JavaScript,PHP-用JavaScript将多个数据库记录发送到变量或表
- 在php和mysql中选择选项.一旦选择了选项,就列出我的sql数据库数据
- 如何使用PHP将javascript变量添加到mysql数据库中
- 将数据保存到数据库(ajax/php)后,使文本字段变灰/禁用
- 如何将翻译后的文本插入数据库 php
- javascript倒计时并更新数据库php
- 根据来自数据库 (PHP) 的数据在 HTML 中添加 grahps
- 将数据从动态表提交到数据库 - PHP
- 如何将DIV ID的值保存到数据库PHP&MySQL
- 在成功更新的数据库PHP上弹出
- 下拉列表加载数据从数据库PHP javascript
- 点击一个简单的HTML按钮,通过jQuery / Javascript写入数据库&PHP
- Fancybox没有'从数据库(php)获取图像时无法工作
- 连接MYSQL数据库[PHP]
- 计算点击按钮的次数错误并插入数据库PHP
- 注册表单没有正确处理到数据库(PHP/MySQL)
- 注册表格不工作和存储数据在数据库(PHP/MYSQL)