正在尝试关注如何使用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
对不起初学者。希望你们能帮忙。谢谢!
首先将form action属性指定到要显示输出的页面,然后您必须显示数据,例如** $ process.php页面中的_POST ['first_name'] **。如果不工作,最好为提交按钮保留一个名称,然后像这样在process.php页面中调用。 if(isset($ _ POST ['submit'])){echo $ _POST ['first_name']; }提供的提交按钮名称是**提交**或您保留的任何名称。这是你会发现输出的东西。 –
你有没有纠正错误@Jas Soloria。 –