![](/img/trans.png)
[英]I am trying to open a https site , using curl in php . But I am getting a blank page
[英]Am using php, json services while i execute below code i am getting a blank page, no data updated in database…correct me if wrong
我是Web服务的初学者。这是我的代码在宁静的Web服务中使用php,json和mysql来更新用户状态。即使我无法将用户信息更新到数据库.plz也会帮助我。 .. !!
<?php
//content header-type
//header('content-type: application/json');
// connect to data-base
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
//on submit action
if(isset($_PUT['update']))
{
if($_SERVER['REQUEST_METHOD'] == "POST")
{
$id = isset($_SERVER['HTTP_ID']) ?
mysql_real_escape_string($_SERVER['HTTP_ID']) : "";
$status = isset($_SERVER['HTTP_STATUS']) ?
mysql_real_escape_string($_SERVER['HTTP_STATUS']) : "";
// validations of code
if(!empty($id)){
$qur = mysql_query("UPDATE `miisky`.`register` SET `status` = '$status' WHERE `register`.`ID` ='$id';");
if($qur){
$json = array("status" => 1, "msg" => "Status updated!!.");
}else{
$json = array("status" => 0, "msg" => "Error updating status");
}
}else{
$json = array("status" => 0, "msg" => "User ID not define");
}
}else{
$json = array("status" => 0, "msg" => "User ID not define");
}
@mysql_close($conn);
/* Output header */
header('Content-type: application/json');
echo json_encode($json);
}
?>
并且听到我的html验证部分,以验证用户以便接收来自用户的输入并更新特定用户的状态。
<body>
<form method = "POST" action = "update2.php">
<h1>Please enter your user id to update your other details</h1>
<label>ID</label>
<input type = "text" name = "ID"><br/>
<label>Status</label>
<input type = "text" name = "status">
<br/>
<input type = "submit" name = "update">
</form>
</body>
HTML表单仅支持GET和POST。 仅方法属性允许html格式的GET和POST请求。 因此,您不能在方法属性中设置PUT方法类型。 在方法属性中更改方法类型。 根据HTML标准,您不能这样做。
<form method = "PUT" action = "update2.php">
更改您的方法属性,例如GET或POST。
<form method = "GET" action = "update2.php">
由于错误的Mehtod属性值,您的if条件不能成立。 您总是从以下位置获得GET价值:
if($_SERVER['REQUEST_METHOD'] == "PUT")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.