我正在尝试从数据库中搜索,以便一旦搜索到数据库并找到匹配项,它会弹出一个消息框并显示“PAID”,它在我的情况下没有响应
我的代码是:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- saved from url=(0077)file:///C:/Users/Emi/AppData/Local/Temp/Web%20Page%20Maker/Preview/page3.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Search Payment</title>
<meta name="generator" content="Web Page Maker">
<style type="text/css">
/*----------Text Styles----------*/
.ws6 {font-size: 8px;}
.ws7 {font-size: 9.3px;}
.ws8 {font-size: 11px;}
.ws9 {font-size: 12px;}
.ws10 {font-size: 13px;}
.ws11 {font-size: 15px;}
.ws12 {font-size: 16px;}
.ws14 {font-size: 19px;}
.ws16 {font-size: 21px;}
.ws18 {font-size: 24px;}
.ws20 {font-size: 27px;}
.ws22 {font-size: 29px;}
.ws24 {font-size: 32px;}
.ws26 {font-size: 35px;}
.ws28 {font-size: 37px;}
.ws36 {font-size: 48px;}
.ws48 {font-size: 64px;}
.ws72 {font-size: 96px;}
.wpmd {font-size: 13px;font-family: Arial,Helvetica,Sans-Serif;font-style: normal;font-weight: normal;}
/*----------Para Styles----------*/
DIV,UL,OL /* Left */
{
margin-top: 0px;
margin-bottom: 0px;
}
</style>
<style type="text/css">
div#container
{
position:relative;
width: 1275px;
margin-top: 0px;
margin-left: auto;
margin-right: auto;
text-align:left;
}
body {text-align:center;margin:0}
</style>
</head>
<body bgcolor="#EBEBEB">
<?php
if(isset($_POST['submit']))
{
include 'mysqlconn.php';
$con = mysqli_connect($host, $dbuser, $pass, $db) or die('Cannot Connect');
$name = mysqli_real_escape_string($con,$_POST['fullname']);
$sql = "SELECT * FROM fees WHERE fullname = '$name'";
if(mysqli_num_rows($sql) !=0)
{
echo ("<script language ='javascript'>
window.alert('Payment Information Found')
window.location.href='home.php';
</script>");
}
}
?>
<div id="container">
<div id="roundrect1" style="position:absolute; overflow:hidden; left:21px; top:17px; width:1233px; height:591px; z-index:0"><img border="0" width="100%" height="100%" alt="" src="./searchpayment_files/shape89HUV.gif"></div>
<div id="image1" style="position:absolute; overflow:hidden; left:60px; top:48px; width:260px; height:67px; z-index:1"><img src="./searchpayment_files/text827854609.gif" alt="" title="" border="0" width="260" height="67"></div>
<div id="hr1" style="position:absolute; overflow:hidden; left:64px; top:126px; width:1169px; height:17px; z-index:2">
<hr size="4" width="1169" color="#C0C0C0">
</div>
<div id="hr2" style="position:absolute; overflow:hidden; left:49px; top:569px; width:1174px; height:17px; z-index:3">
<hr size="2" width="1174">
</div>
<div id="text1" style="position:absolute; overflow:hidden; left:49px; top:583px; width:439px; height:24px; z-index:4">
<div class="wpmd">
<div><font class="ws8">EM Software Nigeria </font><font class="ws8">©</font><font class="ws8"> 2016 All Rights Reserved</font></div>
</div></div>
<form name="form1" style="margin:0px">
<input name="fullname" type="text" style="position:absolute;width:381px;left:308px;top:186px;z-index:7">
<input name="submit" type="submit" value="Search Database" style="position:absolute;left:548px;top:217px;z-index:8">
</form>
<div id="text2" style="position:absolute; overflow:hidden; left:107px; top:186px; width:197px; height:28px; z-index:6">
<div class="wpmd">
<div><font face="Verdana" class="ws11">Search Student Name :</font></div>
</div></div>
<div id="image2" style="position:absolute; overflow:hidden; left:719px; top:186px; width:472px; height:334px; z-index:9"><img src="./searchpayment_files/student-image-2.jpg" alt="" title="" border="0" width="472" height="334"></div>
</div>
</body></html>
这里可能有什么错误
答案 0 :(得分:1)
$sql = "SELECT * FROM fees WHERE fullname = '$name'";
只是将一个字符串赋给变量。
您实际上需要query
数据库。
$sql = mysqli_query($con, "SELECT * FROM fees WHERE fullname = '$name'");