Создаю простое api регистрации и авторизации. При нажатие на кнопку Register должно отправлять пост запрос по урлу
http://xmonitoring.ru/faucet/api2/register.php
но я получаю ошибку 500
html
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body>
<form action="http://xmonitoring.ru/faucet/api2/register.php" method="post">
<table>
<tbody>
<tr>
<td>User Name : </td>
<td><input type="text" name="user_name"></td>
</tr>
<tr>
<td>Password : </td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td>Name : </td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td><input type="submit" value="Register"></td>
</tr>
</tbody></table>
</form>
</body></html>
PHP
<?php
$user_name = $_POST["user_name"];
$user_password = $_POST["password"];
$name = $_POST["name"];
require 'init.php';
if($con)
{
$sql = "SELECT * FROM user_info WHERE user_name='$user_name'";
$result = mysqli_query($con,$sql);
if(mysqli_num_rows($result)>0)
{
$status = "ok";
$result_code = 0;
echo json_encode(array('status'=>$status'result_code'=>$result_code));
}
else
{
$sql = "INSERT INTO user_info(name, user_name, password) values('$name', '$user_name', '$password')";
if(mysqli_query($con, $sql))
{
$status = "ok";
$result_code = 1;
echo json_encode(array('status'=>$status'result_code'=>$result_code));
}
else
{
$status = "failed";
echo json_encode(array('status'=>$status), JSON_FORCE_OBJECT);
}
}
}
else
{
$status = "failed";
echo json_encode(array('status'=>$status), JSON_FORCE_OBJECT);
}
mysqli_close($con);
?>