Naveed Butt
Naveed Butt

Reputation: 2901

PHP Page shows up raw code

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.

Upvotes: 1

Views: 1151

Answers (3)

Tudor Constantin
Tudor Constantin

Reputation: 26861

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

Upvotes: 1

Rukmi Patel
Rukmi Patel

Reputation: 2561

user remove space from "< ?php".

other than this all is fine with coding i think.

Upvotes: 1

sdolgy
sdolgy

Reputation: 7001

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!

Upvotes: 4

Related Questions