我需要幫助根據我在數據庫中檢查的輸入數據解決我的問題之一。如果存在價值,我將轉發到另一個頁面;否則會顯示錯誤。 輸入任何值都會顯示相同的結果,我無法使用php代碼查看回顯。 測試代碼本身工作正常,但與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代碼。
不是'<?php_SELF']?>'try'<?php echo $ _SERVER ['PHP_SELF']?> – vooD