This is a discussion on Submit without form within the PHP Programming forums, part of the Web Development category; How can I send variables from a PHP script to another URL using POST without using forms and hidden variables?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi anand, There are two ways we can submit without form. The most reconizable is using CURL function. For example -> <? $URL="http://www.test.com/test.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$URL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "var=$val&var1=$val1"); curl_exec ($ch); curl_close ($ch); ?> Another way is socket programming. <? // Generate the request header $vHeader = "POST $vURL HTTP/1.1\n". "Host: $vHost\n". "Content-Type: application/x-www-form-urlencoded\n". "Content-Length: $vLength\n\n". "$ReqBody\n"; // Open the connection to the host $vSock = fsockopen($vHost, 80, &$errno, &$errstr); if (!$vSock) { $vResult["errno"] = $errno; $vResult["errstr"] = $errstr; return $vResult; } $vVal = 0; fputs($vSock, $vHeader); while (!feof($vSock)) $vResult[$vVal++] = fgets($vSock, 128); } ?> In this way you can submit the values. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can we submit a form without a submit button? | sundarraja | PHP Programming | 4 | 02-29-2008 09:37 PM |
| Submit a Form using Javascript | velhari | HTML, CSS and Javascript Coding Techniques | 3 | 11-14-2007 03:33 AM |
| How can I have a dropdown form redirect to other pages, without a submit button? | itbarota | HTML, CSS and Javascript Coding Techniques | 2 | 11-01-2007 10:20 PM |
| How can I pass a hidden value to a form and submit that form when a text link is clic | itbarota | HTML, CSS and Javascript Coding Techniques | 1 | 10-17-2007 08:07 AM |
| How do I submit a form or a part of a form without a page refresh in ASP.Net using C# | mobilegeek | ASP and ASP.NET Programming | 1 | 07-23-2007 10:38 PM |