2016-08-14 24 views
0

正在嘗試關注如何使用html向mysql數據庫提交數據。在index.php中輸入的數據無法顯示在process.php

我創建了2個名爲index.php和process.php的php文件。我想展示的是我在index.php中輸入的內容,當我點擊「添加員工」按鈕時,會顯示在process.php上。但沒有出現。

這裏是裏面有什麼的index.php

<!DOCTYPE html> 
<html> 
<head> 
<style> 
label{display:inline-block;width:100px;margin-bottom:10px;} 
</style> 


<title>Add Employee</title> 
</head> 
<body> 

<form method="post" action=""> 
<label>First Name</label> 
<input type="text" name="first_name" /> 
<br /> 
<label>Last Name</label> 
<input type="text" name="last_name" /> 
<br /> 
<label>Department</label> 
<input type="text" name="department" /> 
<br /> 
<label>Email</label> 
<input type="text" name="email" /> 

<br /> 
<input type="submit" value="Add Employee"> 
</form> 

</body> 
</html> 

這裏是形式的截圖。 click here for index.php image

威樂這裏是有什麼process.php

<?php 

print_r($_POST); 

裏面這是顯示了在這個 process.php image

對不起初學者。希望你們能幫忙。謝謝!

+0

首先將form action屬性指定到要顯示輸出的頁面,然後您必須顯示數據,例如** $ process.php頁面中的_POST ['first_name'] **。如果不工作,最好爲提交按鈕保留一個名稱,然後像這樣在process.php頁面中調用。 if(isset($ _ POST ['submit'])){echo $ _POST ['first_name']; }提供的提交按鈕名稱是**提交**或您保留的任何名稱。這是你會發現輸出的東西。 –

+0

你有沒有糾正錯誤@Jas Soloria。 –

回答

0

也許你錯過了「行動」?

<form method="post" action="/process.php"> 
0

您應指定你喜歡這個need.Somethings:

<?php 
print_r($_POST['first_name']); 

或者使用foreach循環得到充分的數組值。

你可以通過填寫action標籤,所以當你submit表格它會去proccess.php頁面。

<form method="post" action="process.php"> 
相關問題