根据我在数据库中检查的输入数据,我需要帮助来解决我的一个问题。如果存在价值,我将转发到另一个页面;否则显示错误。输入任何值显示相同,我无法使用 php 代码查看 echo。单独测试代码可以正常工作,但是当与 html 代码集成时,它会失败。有人可以识别代码中的任何错误吗?如何解决问题?
<!DOCTYPE html>
<?php
if (isset($_POST["submit"])) {
include("connect.php");
$message = NULL;
if(empty($_POST["empid"])) {
$u = FALSE;
$message .= "You have to enter your Employee ID !<br />";
}
else {
$u = intval(stripslashes(trim($_POST["empid"])));
}
if($u) {
$query = "SELECT Emp_ID FROM Data WHERE Emp_ID = '$u' ";
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
if($row){
session_start();
header("Location: ModifyEmpInfo.php?empid=$u");
exit();
}
else {
$message .= "Employee ID provided does not exists. Try again!<br />";
}
}
}
$page_title = "FindEmpolyee";
if(empty($message)) {
echo "<font color=red>So sorry, this page is only for Test members !</font>";
}
else {
echo "<font color=red>";
echo $message;
echo "</font>";
}
?>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="FindEmpInfo_files/form_init.js" id="form_init_script" data-name="">
</script><link href="FindEmpInfo_files/jquery-ui-1.css" type="text/css" rel="stylesheet"><link href="FindEmpInfo_files/normalize.css" type="text/css" rel="stylesheet"><script src="FindEmpInfo_files/jquery-1.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="FindEmpInfo_files/default.css" id="theme">
<title>
FindEmpolyee
</title>
<script src="FindEmpInfo_files/jquery-ui-1.js" type="text/javascript"></script><script src="FindEmpInfo_files/jquery_002.js" type="text/javascript"></script><script src="FindEmpInfo_files/jquery_004.js" type="text/javascript"></script><script src="FindEmpInfo_files/jquery.js" type="text/javascript"></script><script src="FindEmpInfo_files/jquery_003.js" type="text/javascript"></script><script src="FindEmpInfo_files/validation_data.js" type="text/javascript"></script><script src="FindEmpInfo_files/validation.js" type="text/javascript"></script></head>
<body>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" style="WebkitTransform: " id="docContainer" class="fb-toplabel fb-100-item-column selected-object" enctype="multipart/form-data" method="post" action="" novalidate="novalidate" data-form="preview">
<div style="BACKGROUND-COLOR: #d941d9; MIN-HEIGHT: 20px" id="fb-form-header1" class="fb-form-header">
<a id="fb-link-logo1" class="fb-link-logo" href="" target="_blank"><img style="display: none;" id="fb-logo1" class="fb-logo" title="Alternative text" alt="Alternative text" src="FindEmpInfo_files/image_default.png"></a>
</div>
<div id="section1" class="section">
<div id="column1" class="column ui-sortable">
<div style="FILTER: " id="item1" class="fb-item fb-100-item-column">
<div class="fb-header fb-item-alignment-center">
<h2 style="DISPLAY: inline; FONT-FAMILY: comic sans ms; COLOR: #249ee0; FONT-SIZE: 28px">
Find Employee Information
</h2>
</div>
</div>
<div id="item3" class="fb-item fb-100-item-column">
<div class="fb-grouplabel">
<label style="DISPLAY: inline" id="item3_label_0">
Enter Employee Id
</label>
</div>
<div class="fb-input-number">
<input id="item3_number_1" name="empid" min="0" max="999999999" step="1" data-hint="" autocomplete="off" required="" type="number" value="<?php if(isset($_POST["empid"])){echo $_POST["empid"];}?>">
</div>
</div>
</div>
</div>
<div id="fb-submit-button-div" class="fb-item-alignment-center">
<input style="" id="fb-submit-button" class="fb-button-special" value="Submit" type="submit" name="submit">
</div>
</form>
</body></html>
解决方案:问题是名称没有发送到 php 代码。