不能使用C#发布请求

时间:2017-08-09 12:39:39

标签: c# php webrequest

我需要编写简单的注册表单,并且无法使其正常工作,也尝试过KeyValuePair而没有运气。

C#:

        HttpClient _client = new HttpClient();            
        Dictionary<string, string> keys = new Dictionary<string, string>();
        keys.Add("user", "testuser");
        keys.Add("email", "woohoo@ch.com");
        keys.Add("pass", "1q23");
        HttpContent content = new FormUrlEncodedContent(keys);
        string url = "http://web.address/register.php";
        HttpResponseMessage response = await _client.PostAsync(url, content);

PHP:

<?php 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Include config
require_once 'config/db.php';
$sql = new db();
$conn = $sql->connect();

$user = isset($_GET['user']) ? mysqli_real_escape_string($conn, $_GET['user']) :  "";
$email = isset($_GET['email']) ? mysqli_real_escape_string($conn, $_GET['email']) :  "";
$pass = isset($_GET['pass']) ? mysqli_real_escape_string($conn, $_GET['pass']) :  "";


if(!empty($user) && !empty($email) && !empty($pass))
{
    $qur = mysqli_query($conn, "insert into users (username, email, first_name, last_name, password, creation_date) values ('". $user ."', '". $email ."', 'workee', 'worker', '". crypt($pass, '$6$rounds=5000$Ws7S0ftware3v3r$') ."', '". time() ."');");
}
@mysql_close($conn);
?>

但它确实直接来自链接:

http://web.address/register.php?user=testuser&pass=1q23&email=woohoo@ch.com

0 个答案:

没有答案