function saveForm()
{
    global $cookie_jar;
    $uri = "http://127.0.0.1/tomlib/nandu/src/php/main.php?op=saveform";
    $data = array('name' => getRandomText('abcdefghijklmnopqrstuvwxyz', 6), 'phone' => getRandomText('123567890123567890', 11), 'address' => 'you can\'t find me');
    //echo http_build_query($data);
    $ch = curl_init();
    // print_r($ch);
    curl_setopt($ch, CURLOPT_URL, $uri);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
    //curl_setopt ( $ch, CURLOPT_USERAGENT, "monitor" );
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("content-type: application/x-www-form-urlencoded;charset=UTF-8", 'User-Agent: monitor'));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    $return = curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    // print_r(curl_getinfo($ch));
    curl_close($ch);
    //print_r($return);
    print_r($return);
    if ($http_code == 200) {
        // 失败返回空数组
        // print_r($return);
        // $data=getJsonByText($return);
        //print_r($data);
        //echo $data->msg;
        return array();
    }
}
Example #2
0
" data-layout="button"></div>
      </div>

<?php 
} elseif (isset($id) && $id == 'random') {
    $sql = "SELECT Email,Name FROM user WHERE Public = 1 ORDER BY RAND() LIMIT 1";
    if ($result = mysqli_query($con, $sql)) {
        while ($row = mysqli_fetch_row($result)) {
            $email = $row[0];
            $name = $row[1];
            $name = ucwords($name);
        }
        mysqli_free_result($result);
    }
    if (isset($name)) {
        $text = getRandomText();
        $text = str_replace("*name*", $name, $text);
    }
    ?>

  <!-- Random person page -->
      <div id="content" class="row" style="text-align:center">
        <div class="small-12 columns">
          <h2><?php 
    printf($text);
    ?>
</h2><br>
          <h2><b>Help <?php 
    printf($name);
    ?>
 buy this beer</b></h2>