I am new to Slim framework and I would like to pass my code from HTML to another PHP where I have used Slim framework:
<html>
<head>
<title>Login</title>
</head>
<body background="login_bg.jpg">
<form action="/app/api/login_process.php" method="post">
<input type="text" class="form-control" id="username" name="username" placeholder="Username" aria-describedby="basicaddon1">
<input type="password" class="form-control" id="password" name="password" placeholder="Password">
<button type="submit" class="btn btn-success" name="submit" value="submit">
<span class="glyphicon glyphicon-log-in"></span>
Sign In
</button>
</form>
</body>
</html>
Here is my login_process code
<?php
$app->post('/api/login',function($request)
{
require_once('dbconnect.php');
$lid=$request->getParsedBody()['username'];
$pwd=$request->getParsedBody()['password'];
mysql_select_db("slim_db");
$sql_login="select login_id,pwd from login where login_id=".$lid." and pwd=".$pwd;
$res_login=mysql_query($sql_login);
while($row=mysql_fetch_array($res_login))
{
$data[]=$row;
}
if(isset($data))
{
header('Content-Type:application/json');
echo json_encode($data);
}
}
);
This code works when it is used in get method but leaves me error method not allowed method must be one of post for POST method.
I want somebody to guide me with this.
Thanks in advance