标签: post

$_POST 变量保持活动状态多久,PHP 如何决定 post 数组中的内容?

假设我正在构建一个网络应用程序,该应用程序正在连接并基本上解析另一个网站。$.post我的问题是,如果您使用具有多个变量的 php 脚本发布(假设通过速记使用 jquery/ajax )。以这个脚本为例:

$user = $_POST['user'];
$pass = $_POST['pass'];

if(isset($user) && $user !== null){
   if(isset($pass) && $pass !== null)
    echo 'true'
   else
    echo 'false';
}
Run Code Online (Sandbox Code Playgroud)

现在我们的应用程序真的很奇怪(只是一个例子),并决定通过 jQuery 以不同的时间间隔将用户和密码提交到脚本,$.post,这基本上会以 ajax 简写形式提交到脚本并检索数据。我们的应用程序将提交用户首先输入的用户名,但为了惹恼用户,它在五分钟后在另一个单独的调用中提交了密码。

所以从视觉上来说

$.post('script.php',{user: 'username'}) -> posts to the script, but doesn't
return anything, as in this case it would return false

<em>5 minutes later</em>

$.post('script.php',{pass: 'password'}, function(data){
       alert("data returned: " + data);
});
Run Code Online (Sandbox Code Playgroud)

如果脚本全部源自同一页面,脚本会记住之前传递的用户名帖子变量吗?或者它会忘记它并且根本不运行(因为未设置用户名)?

基本上我的总体问题是,您能否在不同时间从同一页面向 php 脚本提交不同的 post 变量,它们是否会在脚本中一起工作?

javascript php jquery post

-1
推荐指数
1
解决办法
2665
查看次数

在php中编码/解码POST数据

我正在使用 cURL 来处理 POST 和检索页面。我注意到我正在尝试发布数据以对其进行编码的站点,例如:

Data=%7B%22Data%22%3A%22%5B%7B%5C%22
Run Code Online (Sandbox Code Playgroud)

如何在 PHP 中编码/解码它?我找到了为我做这件事的网站,但我想学习如何自己做。

php post encode decode

-1
推荐指数
1
解决办法
1万
查看次数

尝试发布具有与数组同名的多个字段的表单

我正在尝试发布一个带有类似于表格条目的字段的表单

我想我最好举个例子:

<form method="post">
    <table>
        <tr>
            <td><label>Name:</label></td>
            <td><input type="text" name="appsDetails[name]" placeholder="Enter name" value=""/></td>
            <td><label>ID:</label></td>
            <td><input type="text" name="appsDetails[id]" placeholder="Enter id" value=""/></td>
            <td><label>Token:</label></td>
            <td><input type="text" name="appsDetails[token]" placeholder="Enter token" value=""/></td>
        </tr>
        
        <tr>
            <td><label>Name:</label></td>
            <td><input type="text" name="appsDetails[name]" placeholder="Enter name" value=""/></td>
            <td><label>ID:</label></td>
            <td><input type="text" name="appsDetails[id]" placeholder="Enter id" value=""/></td>
            <td><label>Token:</label></td>
            <td><input type="text" name="appsDetails[token]" placeholder="Enter token" value=""/></td>
        </tr>
        
        <tr>
            <td><label>Name:</label></td>
            <td><input type="text" name="appsDetails[name]" placeholder="Enter name" value=""/></td>
            <td><label>ID:</label></td>
            <td><input type="text" name="appsDetails[id]" placeholder="Enter id" value=""/></td>
            <td><label>Token:</label></td>
            <td><input type="text" name="appsDetails[token]" placeholder="Enter token" value=""/></td>
        </tr>
        
        
    </table>
</form>
Run Code Online (Sandbox Code Playgroud)

您还可以检查:小提琴示例

当上面的示例提交时,我只得到表中的最后一行。

我的问题:有没有办法像数组中的数组一样做到这一点?如果这是有道理的 …

html php post

-1
推荐指数
1
解决办法
6115
查看次数

在 Python 中的 requests.post() 中发送变量作为数据参数

我试图将变量传递到 requests.post() 中的数据字段,但我继续收到错误,

  Error Response: {'error': {'message': 'Exception while reading request', 
'detail': 'Cannod decode: java.io.StringReader@1659711'}, 'status': 'failure'}
Run Code Online (Sandbox Code Playgroud)

这是我的代码

#Fill array from CSV
temp=[]
for row in csv.iterrows():
    index, data = row
    temp.append(data.tolist())


#Create new asset for all assets in CSV
for index, row in enumerate(temp):
    make = temp[index][0]
    serial = str(temp[index][1])
    date = str(temp[index][2])
    response = requests.post(url, auth=(user, pwd), headers=headers, 
    data='{"asset_tag":"test1", "assigned_to":"test2", 
    "company":"test3", "serial_number":serial}')
Run Code Online (Sandbox Code Playgroud)

我最初尝试使用直接从 CSV 提供数据

str(temp[index][1])
Run Code Online (Sandbox Code Playgroud)

这不起作用,所以我尝试分配str(temp[index][1])给变量serial,然后像这样传递变量,但这也会导致相同的错误。

如果能找到正确的方向就太好了,谢谢!

python post python-requests servicenow servicenow-rest-api

-1
推荐指数
1
解决办法
1万
查看次数

如何保护Web服务URL?

我有一个带有网络服务网址的android应用。如果有人解密我的apk文件,则Web服务URL将变为可见。我正在使用HTTP POST调用Web服务。

任何人都可以通过反编译来自此站点的apk文件来读取代码。

我的注册页面网址遭到黑客入侵,并向其中发送包含发布数据的大量请求。我正在使用,API_KEY并发送API_KEY与数据。API_KEY已存储在gradle.properties文件中。

我没用过

 minifyEnabled true
 shrinkResources true
 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'`  when its got hacked.
Run Code Online (Sandbox Code Playgroud)

经过一番搜索,我知道没有100%安全的方法可以隐藏url。

我的注册代码是:

String link = "http://xxxxxxxxxx.php";

String data = URLEncoder.encode("name", "UTF-8") + "=" + URLEncoder.encode(name, "UTF-8");
data += "&" + URLEncoder.encode("phone", "UTF-8") + "=" + URLEncoder.encode(phone, "UTF-8");
data += "&" + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8"); 

URL url = new URL(link);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data); …
Run Code Online (Sandbox Code Playgroud)

security encryption post android web-services

-1
推荐指数
1
解决办法
1780
查看次数

当HTML表单被设置时,无法获取$ _POST变量值

我希望得到文本输入'name ="quantity"'的值,当我的html表单是使用$ _POST设置时,问题是我每次提交表单时都无法获得它的价值!HTML:

<form method="POST" name="updateform">
<!-- the input text that i want to get it's value when the form is isset -->
 <input type="text" name="quantity" value="<?php echo $row['quantite'] ?>" size="1" class="form-control" />
<!-- the input text that i want to get it's value when the form is isset -->
<a type="submit" name="updateu" data-toggle="tooltip" title="Update" class="btn btn-primary" href='cart.php?id=<?php echo $getid ?>&upt=<?php echo $row['idproduit']; ?>' ><i class="fa fa-clone"></i></a>
                     </form> 
Run Code Online (Sandbox Code Playgroud)

PHP:

//update commande
           if (isset($_POST['updateform'])) {

              $mdf = $_POST['quantity'];
              echo $mdf;
           }else{ …
Run Code Online (Sandbox Code Playgroud)

html php forms post

-1
推荐指数
1
解决办法
162
查看次数

Go 中的简单 HTTP POST 和文件上传

我只需要知道一种在 Go 中使用 HTTP POST 将文件发送到远程服务器的极其简单的方法。我已经尝试了很多复杂的方法但没有运气。我的curl命令是这样的:

curl https://api.example.com/upload \
 --user api:YOUR_API_KEY \
 --data-binary @file.jpg \
 --dump-header apiresponse.txt
Run Code Online (Sandbox Code Playgroud)

我更喜欢不使用多部分的东西。我还更喜欢使用 io.Reader 的东西,这样我以后就可以轻松实现进度条。

upload post http go

-1
推荐指数
1
解决办法
1万
查看次数

$ _POST从JS无法正常工作

我创建了按钮:

<input type = "text" name="consulta" size = "12" value = "565656" id = "consulta" />
<input type="button" value = "Pesquisar" onclick="jawa()" />
Run Code Online (Sandbox Code Playgroud)

而jawa()函数是:

        function jawa(){
            var fieldNameElement = document.getElementById('pesquisa');

                            //just for test if JS takes values....
                            resultado = consulta.value;
            escolha = cbox.value;

            fieldNameElement.innerHTML = "<?echoo();?>";            
        }
Run Code Online (Sandbox Code Playgroud)

和php中的echoo()...

                   <? 
                       function echoo(){

             if (isset($_POST['consulta'])) { 
                $con = $_POST['consulta'];
            }else{
            $con = "not working";
            }

            $conexao =mysql_pconnect("localhost:3306","xxx","xxx");
            mysql_select_db("...",$conexao);

            $str_chamado = "Select * 
                    From
                        `...`.`...` 
                    Where
                        `NU_TELEFONE`='$con'";

                         ...   ?>
Run Code Online (Sandbox Code Playgroud)

它说"Undefined index:consulta"我无法从输入中获取文本,它可以是什么?

html javascript php post input

-2
推荐指数
1
解决办法
117
查看次数

PHP会自动从POST中删除<和>中的数据,为什么?

我有一个带有值的表单输入,例如:

Username <username@somedomain.com>
Run Code Online (Sandbox Code Playgroud)

当我发送表单时,php只有$ _POST:

Username
Run Code Online (Sandbox Code Playgroud)

输入的剩余部分在哪里?怎么弄?

php post

-2
推荐指数
1
解决办法
72
查看次数

PHP cURL 发出相同的请求两次

我正在发出 POST 请求以https://api.mercadolibre.com/oauth/token生成有效的访问令牌。我发送带有一些附加信息的代码以接收回令牌。

我有以下请求类:

class Request {

    private function httpRequest(
        string $method,
        string $url,
        array $headers,
        array $data=array()
    ) {
        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => "",
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => $method,
            CURLOPT_HTTPHEADER => $headers
        ));

        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curl, CURLOPT_HEADER, 0);

        if ($method != "GET" && $data) {
            curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
        }

        if (!$response = curl_exec($curl)) { …
Run Code Online (Sandbox Code Playgroud)

php post curl http

-2
推荐指数
1
解决办法
123
查看次数