21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
include_once("conn/conn.php");
$cx="select * from user order by id desc";
$zx=mysqli_query($conn,$cx);
$bb=mysqli_fetch_row($zx);
if (isset($_POST['submit'])){
//判断输入的用户名 , 密码是否为空
if(isset($_POST['name']) & $_POST['pw']==""){
echo "用户名和密码不能为空"."<a href='index.php'><h1><script>document.write('点击返回')</script></h1></a>";
}else{
if ($_POST['pw'] == $_POST['repw']){ //判断两次输入的密码是否一致
$query = "insert into user (name,pw) values('{$_POST['name']}','{$_POST['pw']}')";
$result=mysqli_query($conn, $query);
echo "<center>添加成功:<a href=select.php?action=select&id=".$bb[0].">点击查询</a></center>";
}else {
echo "两次密码不一致"."<a href='index.php'><h1><script>document.write('点击返回')</script></h1></a>";
}
}
}
发现每次查询后显示的都是我上一个记录, 不知道哪里出问题了呢?<?php
include_once("conn/conn.php");
$cx="select * from user order by id desc";
$zx=mysqli_query($conn,$cx);
$bb=mysqli_fetch_row($zx);
if (isset($_POST['submit'])){
//判断输入的用户名 , 密码是否为空
if(isset($_POST['name']) & $_POST['pw']==""){
echo "用户名和密码不能为空"."<a href='index.php'><h1><script>document.write('点击返回')</script></h1></a>";
}else{
if ($_POST['pw'] == $_POST['repw']){ //判断两次输入的密码是否一致
$query = "insert into user (name,pw) values('{$_POST['name']}','{$_POST['pw']}')";
$result=mysqli_query($conn, $query);
echo "<center>添加成功:<a href=select.php?action=select&id=".$result[0].">点击查询</a></center>";
}else {
echo "两次密码不一致"."<a href='index.php'><h1><script>document.write('点击返回')</script></h1></a>";
}
}
}
include_once("conn/conn.php");
if (isset($_POST['submit'])){
//判断输入的用户名 , 密码是否为空
if(isset($_POST['name']) & $_POST['pw']==""){
echo "用户名和密码不能为空"."<a href='index.php'><h1><script>document.write('点击返回')</script></h1></a>";
}else{
if ($_POST['pw'] == $_POST['repw']){ //判断两次输入的密码是否一致
$query = "insert into user (name,pw) values('{$_POST['name']}','{$_POST['pw']}')";
$result=mysqli_query($conn, $query);
if( $result ){
//添加成功后,查询数据
$cx="select * from user order by id desc";
$zx=mysqli_query($conn,$cx);
$bb=mysqli_fetch_row($zx);
echo "<center>添加成功:<a href=select.php?action=select&id=".$bb[0].">点击查询</a></center>";
}else{
echo "注册失败,请重新操作"."<a href='index.php'><h1><script>document.write('点击返回')</script></h1></a>";
}
}else {
echo "两次密码不一致"."<a href='index.php'><h1><script>document.write('点击返回')</script></h1></a>";
}
}
}