Page 1 of 1

how to use the method post without submit?

Posted: Thu Sep 13, 2007 3:41 pm
by peri22
[s]hallo[/s] hello
i ask how i can use data in page [s]thet[/s] that get the data form "$_post"whit out use the submit [s]botten[/s] button
i use now only in "get" method

Code: Select all

<?php
$fp = fsockopen("localhost", 80, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    $out = "GET /test2.php?name=john&pass=123&pass2=123&email=john@12323i HTTP/1.1\r\n";
    $out .= "Host: localhost\r\n";
    $out .= "Connection: Close\r\n\r\n";
    fwrite($fp, $out);
    fclose($fp);
}
?>
if i [s]chang[/s] change the the page read in $_post its not work for me and i try [s]chang[/s] change it to -->POST /test2.php?name=john&pass=
i cant [s]chang[/s] change the page test2.php to use the $_get method/
[s]plz[/s] please help me
[s]tnx[/s] thanks and good day
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.

Posted: Thu Sep 13, 2007 4:21 pm
by mrkite
you could either use POST properly (define content-type and content-length headers, then send the query as the body)

or you can use stream contexts. I prefer stream contexts:

Code: Select all

$query=http_build_query('blah'=>"one", 'blah2'=>"two", 'blah3'=>"three");
$opts=array(
   'http'=>array(
      'method'=>'POST',
      'header'=>"Content-type: application/x-www-form-urlencoded\r\n".
                       "Content-Length: ".strlen($query)."\r\n",
      'content'=>$query
   )
);

$context=stream_context_create($opts);
echo file_get_contents("http://wherever.com/blah.php",false,$context);
There you go, POST via file_get_contents.

Posted: Thu Sep 13, 2007 6:11 pm
by peri22
first big thanks and sorry about my [s]misteks[/s] mistakes :)
i not good in stream contexts so i try like that

Code: Select all

<?php
query=http_build_query(name=john, pass=123, pass2=123,email=wew@wew); 

$fp = fsockopen("localhost", 80, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    
    $out = "POST /test2.php HTTP/1.1\r\n";
    $out .= "Host: localhost\r\n";
    $out = "Content-type: application/x-www-form-urlencoded\r\n";
    $out="Content-Length: .strlen($query).\r\n";
    $out="content:$query\r\n";
    $out .= "Connection: Close\r\n\r\n";
    fwrite($fp, $out);
    fclose($fp);
  ) 
}
?>
what [s]u[/s] you [s]sey[/s] say its good?
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.

Posted: Thu Sep 13, 2007 6:16 pm
by mrkite

Code: Select all

<?php
$query=http_build_query('name'='john', 'pass'='123', 'pass2'='123','email'='wew@wew');

$fp = fsockopen("localhost", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {

$out = "POST /test2.php HTTP/1.1\r\n";
$out.= "Host: localhost\r\n";
$out.= "Content-type: application/x-www-form-urlencoded\r\n";
$out.="Content-Length: ".strlen($query)."\r\n";
$out.= "Connection: Close\r\n\r\n";
$out.=$query;
fwrite($fp, $out);
fclose($fp);
)
}
?>