PHP Page shows up raw code

允我心安 提交于 2019-12-20 04:11:18

问题


My PHP File is showing raw code in the browser when accessed through a POST request.

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...

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>&nbsp;</td>
            <td><span style="font-weight: normal;">Already have a login?</span>&nbsp;<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>&nbsp;

            </td>
            <td>
                <input type="submit" value="Sign up" id="btnSignUp" name="btnSignUp" style="width: 100px;" />
            <!--onClick="btnSignUp_click();" --></td>
        </tr>
    </table>
    </form>

Just for the information, I am trying to run the PHP on IIS 7 on a Windows 7 machine.


回答1:


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!




回答2:


user remove space from "< ?php".

other than this all is fine with coding i think.




回答3:


Try changing < ?php with <?php and see if that works.

If that doesn't, make sure that Apache knows to interpret php files in the directory of your file as php scripts



来源:https://stackoverflow.com/questions/6633626/php-page-shows-up-raw-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!