作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含 2 个字段名称和年龄的 html 表单,我创建了一个 MySQL 数据库,当使用 php API 提交到我的数据库时,我需要存储 html 中的值...我熟悉 php,但我需要使用 API 在提交表单时从 html 页面发送值...我用于 html 和 API 的代码。
Index.html
<form class="col s12" method="post" action="">
<input id="name" type="text" name="Name">
<input id="name" type="text" name="Age">
<button type="submit" name="btn_login">Request</button>
</form>
reg.php(api)
$app->post('/createstudent', function () use ($app) {
verifyRequiredParams(array('Name', 'Age'));
//Creating a response array
$response = array();
//reading post parameters
$name = $app->request->post('Name');
$age = $app->request->post('Age');
//Creating a DbOperation object
$db = new DbOperation();
//Calling the method createStudent to add student to the database
$res = $db->createStudent($name,$age);
//If the result returned is 0 means success
if ($res == 0) {
//Making the response error false
$response["error"] = false;
//Adding a success message
$response["message"] = "You are successfully registered";
//Displaying response
echoResponse(201, $response);
//If the result returned is 1 means failure
} else if ($res == 1) {
$response["error"] = true;
$response["message"] = "Oops! An error occurred while registereing";
echoResponse(200, $response);
//If the result returned is 2 means user already exist
}
});
现在我想知道在提交 html 表单时我应该进一步做什么来将值发送到数据库
最佳答案
查看 WAMP 示例之一。 http://www.homeandlearn.co.uk/php/php1p3.html
关于php - 使用 php Rest api 将 Html 连接到 Mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42479495/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!