自己写的代码 php不报错 是用mysqli的 但是insert语句不执行
<?php$conn=mysqli_connect("localhost","root","","jiakao")ordie("数据库连接错误");mysqli_quer...
<?php
$conn=mysqli_connect("localhost","root","","jiakao")or die("数据库连接错误");
mysqli_query($conn,"set names utf8");
if(isset($_POST["submit"]))
{
$sql="SELECT * FROM `l-guan` WHERE namel='$_POST[mz]'";
$query=mysqli_query($conn,$sql);
$num=mysqli_num_rows($query);
if($num)
{
echo"<script language='javascript'>alert('该管理员已存在')</script>";
}
else
{
$sql="insert into `shq`(`xu`,`mz`,`mima`,`reason`)values('','$_POST[mz]','$_POST[mima]','$_POST[reason]')";
mysqli_query($conn,$sql);
echo"<script language='javascript'>alert('申请成功 请耐心等待审核')</script>";
echo"<script language='javascript'>location.href=('shouye.php');</script>";
}
}
?>
<body>
<div class="header">
<a href="#">
</a>
<p>
</div>
<div class="row-fluid login-wrapper">
<div class="box">
<div class="content-wrap">
<h6><font face="微软雅黑">管 理 员 申 请</font></h6>
<form action="signup.php" method="post" name="sq" onsubmit="return check()">
<input name="mz" class="span12" type="text" placeholder="用户名" />
<input name="mima" class="span12" type="password" placeholder="输入密码" />
<input name="remima" class="span12" type="password" placeholder="确认密码" />
<input name="reason" class="span12" type="text" placeholder="申请理由" />
<input name="submit" type="submit" value="提交申请">
</div>
</div>
<div class="span4 already">
<a href="signin.php"><font face="微软雅黑">登 录</font></a>
<a href="shouye.php"><font face="微软雅黑">返回首页</font></a>
</div>
</div>
</form> 展开
$conn=mysqli_connect("localhost","root","","jiakao")or die("数据库连接错误");
mysqli_query($conn,"set names utf8");
if(isset($_POST["submit"]))
{
$sql="SELECT * FROM `l-guan` WHERE namel='$_POST[mz]'";
$query=mysqli_query($conn,$sql);
$num=mysqli_num_rows($query);
if($num)
{
echo"<script language='javascript'>alert('该管理员已存在')</script>";
}
else
{
$sql="insert into `shq`(`xu`,`mz`,`mima`,`reason`)values('','$_POST[mz]','$_POST[mima]','$_POST[reason]')";
mysqli_query($conn,$sql);
echo"<script language='javascript'>alert('申请成功 请耐心等待审核')</script>";
echo"<script language='javascript'>location.href=('shouye.php');</script>";
}
}
?>
<body>
<div class="header">
<a href="#">
</a>
<p>
</div>
<div class="row-fluid login-wrapper">
<div class="box">
<div class="content-wrap">
<h6><font face="微软雅黑">管 理 员 申 请</font></h6>
<form action="signup.php" method="post" name="sq" onsubmit="return check()">
<input name="mz" class="span12" type="text" placeholder="用户名" />
<input name="mima" class="span12" type="password" placeholder="输入密码" />
<input name="remima" class="span12" type="password" placeholder="确认密码" />
<input name="reason" class="span12" type="text" placeholder="申请理由" />
<input name="submit" type="submit" value="提交申请">
</div>
</div>
<div class="span4 already">
<a href="signin.php"><font face="微软雅黑">登 录</font></a>
<a href="shouye.php"><font face="微软雅黑">返回首页</font></a>
</div>
</div>
</form> 展开
推荐于2016-01-27
展开全部
mysqli_query($conn,$sql) or die(mysqli_error( $conn ));
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询