- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
$con = mysql_connect('localhost', 'root','');
mysql_select_db ('product');
echo "Connected to database";
session_start();
?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Register</title>
<script type="text/javascript" src="assets/js/bootstrap.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
<link rel="stylesheet" href="reg.css" />
<!-- Google Fonts -->
<link href='https://fonts.googleapis.com/css?family=Passion+One' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Oxygen' rel='stylesheet' type='text/css'>
<script src="jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
<table align="center">
<td>
<tr>
<div align="center" style="size:30%;" class="container">
<div class="row main" style="width:30%;">
<div class="panel-heading">
<div class="panel-title text-center">
<h1 class="title">Register Here</h1>
<hr />
</div>
</div>
<div class="main-login main-center">
<form class="form-horizontal" method="post" action="<?php
echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div align="left" class="form-group">
<label name="name" class="cols-sm-2 control-label">Your Name</label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
<input type="text" class="form-control" name="name" placeholder="Enter your Name"/>
</div>
</div>
</div>
<div align="left" class="form-group">
<label name="email" class="cols-sm-2 control-label">Your Email</label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope fa" aria-hidden="true"></i></span>
<input type="text" class="form-control" name="email" placeholder="Enter your Email"/>
</div>
</div>
</div>
<div align="left" class="form-group">
<label name="user_name" class="cols-sm-2 control-label">Username</label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-users fa" aria-hidden="true"></i></span>
<input type="text" class="form-control" name="user_name" placeholder="Enter your Username"/>
</div>
</div>
</div>
<div align="left" class="form-group">
<label name="password" class="cols-sm-2 control-label">Password</label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock fa-lg" aria-hidden="true"></i></span>
<input type="password" class="form-control" name="password" placeholder="Enter your Password"/>
</div>
</div>
</div>
<div align="left" class="form-group">
<label name="confirm_password" class="cols-sm-2 control-label">Confirm Password</label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock fa-lg" aria-hidden="true"></i></span>
<input type="password" class="form-control" name="confirm_password" placeholder="Confirm your Password"/>
</div>
</div>
</div>enter code here
<div align="left" class="form-group ">
<button type="button" name="submit" class="btn btn-primary btn-lg btn-block login-button">Register</button>
</div>
<div class="login-register">
<a href="log.php">Already registered? Login here</a>
</div>
</form>
</div>
</div>
</div>
</tr>
</td>
</table>
<?php
if (isset($_POST['submit']))
{
$name = $_POST['name'];
$username = $_POST['user_name'];
$email = $_POST['email'];
$password = $_POST['password'];
$cpassword = $_POST['confirm_password'];
$slquery = "SELECT * FROM customer WHERE email = '$email'";
$selectresult = mysql_query($slquery);
if(empty($_POST['name']))
{
$nameErr='Enter Your Name!';
}
else
{
$user = test_input($_POST['name']);
if(!preg_match('/^[a-zA-Z0-9@_]*$/',$user))
{
$nameErr=' Re-Enter Your Name! Format Inccorrect!( only alpha, numbers,@_ are allowed)';
}
}
if(empty($_POST['password']))
{
$passErr='Enter Your Password!';
}
else
{
$user = test_input($_POST['password']);
if(!preg_match('/^[a-zA-Z0-9@_]*$/',$pass))
{
$passErr='Invalid Format! Re-Enter Password!';
}
}
if(mysql_num_rows($selectresult)>0)
{
$msg = 'email already exists';
}
elseif($password != $cpassword){
$msg = "passwords doesn't match";
}
else{
$query = "INSERT INTO customer (name,email,user_name, password,confirm_password, ) VALUES ('
$name', '$username', '$password', '$cpassword', '$email')";
$result = mysql_query($query);
if($result){
$msg = "User Created Successfully.";
}
}
}
?>
</body>
</html>
我正在尝试创建一个带有验证的注册表单。我使用了一些 Bootstrap 进行前端设计,然后使用 Mysql 数据库和 php。
当我点击提交注册表时,它不会验证字段值。请有人告诉我这有什么问题。而且,它没有显示错误。我不知道为什么这不起作用。
Thank you in Advance.
最佳答案
只需更改此行
<button type="button" name="submit" class="btn btn-primary btn-lg btn-block login-button">Register</button>
到
<button type="submit" name="submit" class="btn btn-primary btn-lg btn-block login-button">Register</button>
您使用了按钮
,因此表单未提交。将其更改为提交
类型
编辑
注意:请开始使用 PDO 或 mysqli
请检查以下几点:
1) 您已使用 test_input()
但未在显示的代码中定义。
2) 您的查询在 confirm_password
之后有额外的 ,
。
3) 插入查询将不起作用。有一些错误:
$query = "INSERT INTO customer (name,user_name, password,confirm_password, email) VALUES ('
$name', '$username', '$password', '$cpassword', '$email')";
4) 无需存储confirm_password
关于php - 我不知道为什么当我提交时isset函数不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45930986/
我有以下不能正常工作的 $_GET['category'] 也可以等于 0。 if ( empty( $_GET['category'] ) ){ // do something } else
我最近被安排做一个需要一些PHP的项目,我对PHP了解不多。站点中有几个实例,单击按钮后,用户会被重定向到带有一些 URL 参数的另一个页面。然后下一页使用 $_GET 获取这些参数并继续。 代码中的
如果我使用此代码将数字作为输入,它可以正常工作 Hours: Hours: Minutes: Hours: Minutes
我希望扩展我的 PHP 知识,但我遇到了一些我不确定它是什么或什至不知道如何搜索它的东西。我正在查看 php.net isset 代码,我看到了 isset($_GET['something']) ?
isset($var) == "Test" 和 isset($var) && $var == 'Test" 有什么区别? 最佳答案 这里是一个简短的例子: $var = "Chuck Test"; v
isset($var) == "Test" 和 isset($var) && $var == 'Test" 有什么区别? 最佳答案 这里是一个简短的例子: $var = "Chuck Test"; v
例如,如果我实现一些简单的对象缓存,哪种方法更快? 1. return isset($cache[$cls]) ? $cache[$cls] : $cache[$cls] = new $cls; 2.
{if isset({$LANG.domainmoreinfo}){$LANG.domainmoreinfo}{/if} 这似乎是一个不正确的语法,有人能告诉我我做错了什么吗? 也许我们不能在“$LA
这个问题在这里已经有了答案: Weak typing in PHP: why use isset at all? (9 个回答) 关闭 6 年前。 我是 PHP 的初学者,想知道这之间有什么区别 $
根据文档 isset 条款“测试此项目中是否已设置给定属性”。我不明白设置属性时 isset 返回 true 还是 false 在下面的代码片段中,当 env.JAVA_HOME 未设置时,java.
这个问题在这里已经有了答案: Search nested object for property (4 个答案) 关闭 2 年前。 我找不到与我的问题非常相似的问题,但如果你能找到一个,请随时告诉我
有人可以帮助我学习 PHP 吗?我想创建简单的表单,并在添加“isset 函数”后返回所有表单。 Monitors Graphics Peripher
当我打印它时,我有 $list 然后我得到以下输出 AWeberEntry Object ( [_privateData:protected] => Array ( [0] =
知道 PHP 的 memcached 模块是否支持某种 isset() 方法吗? 以下案例: Memcached::set('foo', false); if(Memcached::get('foo'
我正在阅读“Head First PHP & MySQL”一书,书中的许多部分都有用于处理 HTML 表单的代码片段。他们是这样开始的: if (isset($_POST['submit'])){ .
有没有一种快捷方式可以将$_GET['values']赋值给变量? 我现在和其他人一样: if(isset($_GET['type'],$_GET['case']) $type = $_GET[
知道 PHP 的 memcached 模块是否支持某种 isset() 方法吗? 以下案例: Memcached::set('foo', false); if(Memcached::get('foo'
我有一个表格 > Note Add More Notes Next call date
这是我的Python代码: if onerow[0]['result'] is None or not result['GetOdds'][0]['result']is None: 当result为空
我创建了一个 isset 函数来检查变量是否已定义且不为空。这是我的代码: isset = function(a) { if ((typeof (a) === 'undefined') ||
我是一名优秀的程序员,十分优秀!