简体   繁体   English

当我发送这个表单时,有人可以帮助我,我会显示php而不是执行php代码

[英]can someone help me when i send this form i get the php displayed instead of it executed the php code

when ever i try to setup a html form that send the information over to mysql the php code is always displayed instead of being executed here is my code can someone please explain where i am going wrong spent week trolling the internet looking for a answer and still haven't got any further on in my work 当我尝试设置一个html表单,将信息发送到mysql时,PHP代码始终显示而不是在这里执行是我的代码可以有人请解释我在哪里错误花了一周拖着互联网寻找答案仍然在我的工作中没有进一步

html form page: html表单页面:

<html>
<body>

<form action="insert.php" method="post">
students name: <input type="text" name="studentsname">
students form: <input type="text" name="studentsform">
teachers id: <input type="text" name="teachersid">
<input type="submit">
</form>

</body>
</html>

now this next bit is the code for mysql database 现在这下一步是mysql数据库的代码

<?php
$con=mysqli_connect("localhost","root","","onduty");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$sql="INSERT INTO on duty request (studentsname, studentsform, teachersid)
VALUES
('$_POST[studentsname]','$_POST[studentsform]','$_POST[teachersid]')";

if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";

mysqli_close($con);
?>

i could really use someones help to explain to me why the php code is being displayed instead of being executed thanks daniel 我真的可以使用someones帮助向我解释为什么显示php代码而不是执行感谢daniel

If your script is not running and you are seeing php code in your browser it sounds like your web server is not configured correctly. 如果您的脚本没有运行,并且您在浏览器中看到php代码,则听起来您的Web服务器配置不正确。

Could be many things; 可能是很多东西; needs more information. 需要更多信息。 What web server are you running, what version of php is installed, is php installed correctly, etc. 您正在运行什么Web服务器,安装了什么版本的php,是否正确安装了php等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM