IT Community - Software Programming, Web Development and Technical Support

Submit without form

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?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-19-2007, 03:19 AM
Anand Anand is offline
D-Web Programmer
 
Join Date: Mar 2007
Posts: 52
Anand is on a distinguished road
Default Submit without form

How can I send variables from a PHP script to another URL using POST without using forms and hidden variables?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-19-2007, 03:36 AM
venkat_charya venkat_charya is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 118
venkat_charya is on a distinguished road
Thumbs up Re: Submit without form

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 02:42 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0