user3308335 user3308335 - 1 year ago 63
PHP Question

Can't connect to a php file from nginx server

I have an nginx server set up on my rpi2 that works fine and is linked to my website. I have php5-fpm set up as well and my index.php file is simple, just to test it out.

<?php phpinfo(); ?>

going to works and it shows the php info screen. Going to works, as well as, which shows the default "Welcome to nginx!" screen.

However, I am working on an accounts system and set up this simple page and put it in the www folder that includes my index files and named it login.php:



<meta http=equiv="Content Type" content="text/html; charset=utf-8" />
<title>Member System - Login</title>


$form="<form action='./login.php' method='post'></form>";
<td><input type='text' name='user' /></td>
<td><input type='password' name='password' /></td>
<td><input type='submit' name='loginbtn' value='Login' /></td>

if ($_POST['loginbtn']){

$user= $_POST['user'];
$password = $_POST['password'];

if ($user) {
echo "$user - $password <hr /> $form";
} else echo "You must enter your password. $form";
} else echo "You must enter your username. $form";

} else {
echo $form;



However, whenever I go to on a separate PC, Chrome says "The page isn't working. is currently unable to handle this request." With HTTP error 500, which is an internal server error.

In the www folder I ran

sudo cp index.php test.php

and then reloaded nginx. Going to worked so I'm assuming the error lies within my login.php file but I haven't been able to figure it out.

What is wrong with my code? Any help is appreciated

Answer Source

If the example shown is the contents of login.php you have an error in your code

$form="<form action='./login.php' method='post'></form>";

will not work as <table> is hanging on it's own line outside of the string, delete the "; and it may fix the problem

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download