PHP页面显示原始代码 [英] PHP Page shows up raw code
问题描述
通过POST
请求访问时,我的PHP文件在浏览器中显示原始代码.
My PHP File is showing raw code in the browser when accessed through a POST
request.
我已经在本地主机上创建了phpinfo.php
页,并且通过简单的GET
请求访问它时,它可以正确显示该页,因此我认为我的PHP已全部设置好了.
I've created a phpinfo.php
page on the localhost and when accessing it via a simple GET
request, it shows the page properly, so I assume my PHP is all set up...
我是PHP的新手,想解决此问题.这是PHP文件的代码...
I am new to PHP and want to fix this. Here is the code for the PHP file...
< ?php
mysql_connect("localhost", "root", "Elixir") or die('Cannot connect to the dataabase because ' . mysql_error());
mysql_select_db("sslweb") or die('database name invalid... ' . mysql_error());
$Query = "INSERT INTO 'Login' ('UserName','FName','LName','Email','UserPassword') VALUES ('" . $_POST['UserName'] . "', '" . $_POST['FName'] . "','" . $_POST['LName'] . "','" . $_POST['Email'] . "','" . $_POST['Password'] . "')";
mysql_query($Query);
mysql_close();
header("Location: login.html");
?>
这是动态调用此页面的代码
and here is the code that calls this page dynamically
<form id="frmSignUp" method="post" action="SignUp.php">
<table class="Form" cellpadding="0" cellspacing="0" border="0" align="center" style="width: 300px;">
<tr>
<td>
<span>First Name:</span>
</td>
<td>
<input type="text" id="txtFName" name="txtFName" />
</td>
</tr>
<tr>
<td>
<span>Last Name:</span>
</td>
<td>
<input type="text" id="txtLName" name="txtLName" />
</td>
</tr>
<tr>
<td>
<span>E-mail Address:</span>
</td>
<td>
<input type="text" id="txtEmail" name="txtEmail" />
</td>
</tr>
<tr>
<td>
<span>User Name:</span>
</td>
<td>
<input type="text" id="txtUserName" name="txtUserName" />
</td>
</tr>
<tr>
<td>
<span>Password:</span>
</td>
<td>
<input type="password" id="txtPassword" name="txtPassword" />
</td>
</tr>
<tr>
<td>
<span>Confirm Password:</span>
</td>
<td>
<input type="password" id="txtConfirmPassword" name="txtConfirmPassword" />
</td>
</tr>
<tr>
<td> </td>
<td><span style="font-weight: normal;">Already have a login?</span> <a href="Login.html">Sign in</a>
</td>
</tr>
<tr>
<td colspan="2">
<img alt="" src="images/spacer.gif" height="12px" border="0" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" value="Sign up" id="btnSignUp" name="btnSignUp" style="width: 100px;" />
<!--onClick="btnSignUp_click();" --></td>
</tr>
</table>
</form>
仅供参考,我试图在Windows 7
机器上的IIS 7
上运行PHP.
Just for the information, I am trying to run the PHP on IIS 7
on a Windows 7
machine.
推荐答案
也许是愚蠢的回答,但是您是否尝试过将< ?php
更改为<?php
?可能是因为语法无效,解析器未对其进行解析...只是一个疯狂的猜测!
Maybe it's a daft response, but have you tried changing < ?php
to <?php
? It could be that the parser isn't parsing it because it's not valid syntax ... just a wild guess!
这篇关于PHP页面显示原始代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!