Problem in invoking database Php code from HTML on Nginx Server

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
zak100
New php-forum User
New php-forum User
Posts: 10
Joined: Fri May 24, 2019 1:36 pm

Thu Oct 31, 2019 2:24 pm

Hi,
My form code is:
<form action = "firstsql2.php" method = "post">
<input type = "email" name = "email" required ="required"/>
<input type = "password" name = "password" required ="required"/>
<input type = "checkbox" name = "remember_me" value ="remember me"/>
<input type = "submit" value = "Submit"/>
</form>

My php code is:
<?php
if($_SERVER["REQUEST_METHOD"] == "POST")
$email = $_POST["email"];
$pw =$_POST["password"];

$mysql_host = "localhost";
$mysql_u = "root";
$mysql_pw = "";
$mysql_database = "test";

$mysqli = new mysqli($mysql_host, $mysql_u, $mysql_pw, $mysql_database);
if ($mysqli->connect_error){
die('Error : ('. $mysql->connect_errno .') '. $mysql->connect_error);

$statment = "select * from user where email = '$email' and password = md5 ('$password');

if($statement->execute()){
print "test succeded";
else
print "test failed" . $mysqli->error;

>

I found following error in the log file:
2019/10/31 16:58:50 [error] 1180#1180: *7 FastCGI sent in stderr: “PHP message: PHP Parse error: syntax error, unexpected ‘test’ (T_STRING) in /var/www/html/firstsql2.php on line 18” while reading response header from upstream, client: 127.0.0.1, server: _, request: “POST /firstsql2.php HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php/php7.2-fpm.sock:”, host: “localhost”, referrer: “http://localhost/sql1.html

show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
±-------------------+
5 rows in set (0.00 sec)

Some body please guide me.

Zulfi.
Post Reply