我已經創建了一個名爲「employee.php」的表單頁面來接收用戶數據。另外我有另一個名爲SQLConnectionProcess.php的文件,其中包含將employee.php中的表單鏈接到sql表的代碼。數據庫的名稱是「員工信息」,表的名稱是「員工信息」。我正在使用phpmyadmin和XAMPP進行本地服務器測試。我無法將我的html表單鏈接到mysql表?
employee.php代碼:
<html>
<body>
<form name="EmployeeDatabase" action="SQLConnectionProcess.php" method="post">
<link rel="stylesheet" href="css.css">
<h1>EMPLOYEE DATABASE</h1>
Employe Card NO: <input type="text" name="cardNO" ><br><br>
Employee NO: <input type="text" name="employeeNO" ><br><br>
Employee Name: <input type="text" name="employeename"><br><br>
Nationality: <input type="text" name="nationality"><br><br>
Profession: <input type="text" name="profession"><br><br>
DOB: <input type="text" name="DOB"><br><br>
DOJ: <input type="text" name="DOJ"><br><br>
DOA(VisitVisa): <input type="text" name="DOA"><br><br>
Company Code: <input type="text" name="companycode"><br><br>
Sponsor Code: <input type="text" name="sponsorcode"><br><br>
Visa Type: <input type="text" name="visatype"><br><br>
Status: <input type="text" name="status"><br><br>
<input type="submit" name="formSubmit" value="Submit">
</form>
</body>
</html>
SQLConnectionProcess.php代碼:
if(isset($_POST['formSubmit'])){
$cardNO= $_POST['cardNO'];
$employeeNO= $_POST['employeeNO'];
$employeename= $_POST['employeename'];
$nationality= $_POST['nationality'];
$profession= $_POST['profession'];
$DOB= $_POST['DOB'];
$DOJ= $_POST['DOJ'];
$DOA= $_POST['DOA'];
$companycode = $_POST['companycode'];
$sponsorcode= $_POST['sponsorcode'];
$visatype= $_POST['visatype'];
$status= $_POST['status'];
mysqli_connect('localhost','root','password','employee information');
$sql = sprintf("INSERT INTO table_employee info(Employee Card NO,Employee NO,Employee Name,Nationality,Profession,DOB,DOJ,DOA(VisitVisa),Company Code,Sponsor Code,Visa Type,Status) VALUES ('','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",$cardNO,$employeeNO,$employeename,$nationality,$profession,$DOB,$DOJ,$DOA,$companycode,$sponsorcode,$visatype,$status);
mysqli_query($sql);
但是,當我從employee.php提交我的形式我重定向到顯示所有的代碼了新的一頁在SQLConnectionProcess.php中。我無法弄清楚編碼錯誤。請幫助我.....
外接線的ini_set( 「display_errors設置」,1);在你的代碼前面。並查看錯誤。 –
看看你的apache配置文件......聽起來好像你的php模塊沒有加載 – Joze
使用標籤也會「}」關閉if缺失。 – RJParikh