Php 使用post方法使用slim框架进行登录页面身份验证
我是Slim framework的新手,我想将我的代码从HTML传递到另一个使用过Slim framework的PHP:Php 使用post方法使用slim框架进行登录页面身份验证,php,html,slim,Php,Html,Slim,我是Slim framework的新手,我想将我的代码从HTML传递到另一个使用过Slim framework的PHP: <html> <head> <title>Login</title> </head> <body background="login_bg.jpg"> <form action="/app/api/login_process.php" method="post">
<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>
登录
登录
这是我的登录过程代码
<?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);
}
}
);
我认为路由的问题在于,将/app/api/login\u process.php
替换为/app/api/login
:
<form action="/app/api/login" method="post">
如果您的应用程序
和api
在同一台服务器上,并且您的.htaccess
设置正确,下面的说明应该可以解决问题
<form action="/api/login" method="post">
哪一个超薄版本?检查表单上的操作属性。
<form action="path_to_api_php" method="post">