Submitting form automatically... PHP
Moderator: General Moderators
Submitting form automatically... PHP
Hello bro...
I have got a prob! I want to submit a form automatically when I get notification
from my friend.
Is that possible?
The following code does work when I call the file from a browser but it is not
submitting the form if it is called by another server!
$frmMain="<form name='frmMain' action='...index.php' method='post'>";
$frmMain.="<input type='hidden' name='Body' value='Test'>";
$frmMain.="</form>";
$frmMain.="<script language=javascript>document.forms.frmMain.submit()</script>";
echo $frmMain;
Am I doing anything wrong here?
I have got a prob! I want to submit a form automatically when I get notification
from my friend.
Is that possible?
The following code does work when I call the file from a browser but it is not
submitting the form if it is called by another server!
$frmMain="<form name='frmMain' action='...index.php' method='post'>";
$frmMain.="<input type='hidden' name='Body' value='Test'>";
$frmMain.="</form>";
$frmMain.="<script language=javascript>document.forms.frmMain.submit()</script>";
echo $frmMain;
Am I doing anything wrong here?
hmm...
Well let me explain it then...
I have a Paypal account where I get notification from if someone donates on my site. Paypal calls my notification.php
along with some arguments. Then notification.php file updates my database and sends a mail back to the payer.
I just wanted to add a HTML FORM that will POST some processed data to my another PHP file. That would be verymuch
helpful for me if I could do it!
So... is there anyway to POST the form automatically? I am not very good in PHP as I just started learning... PLease
help!
I have a Paypal account where I get notification from if someone donates on my site. Paypal calls my notification.php
along with some arguments. Then notification.php file updates my database and sends a mail back to the payer.
I just wanted to add a HTML FORM that will POST some processed data to my another PHP file. That would be verymuch
helpful for me if I could do it!
So... is there anyway to POST the form automatically? I am not very good in PHP as I just started learning... PLease
help!
Ohh Sorry!
Oh... my mistake...
It POST data to another server's Form!
$frmMain="<form name='frmMain' action='http://anotherServer.com' method='post'>";
$frmMain.="<input type='hidden' name='Body' value='Test'>";
$frmMain.="</form>";
$frmMain.="<script language=javascript>document.forms.frmMain.submit()</script>";
echo $frmMain;
I am just dying sorting this problem out!
Help!!!
It POST data to another server's Form!
$frmMain="<form name='frmMain' action='http://anotherServer.com' method='post'>";
$frmMain.="<input type='hidden' name='Body' value='Test'>";
$frmMain.="</form>";
$frmMain.="<script language=javascript>document.forms.frmMain.submit()</script>";
echo $frmMain;
I am just dying sorting this problem out!
Help!!!
Last edited by ahsan on Fri Feb 24, 2006 8:19 pm, edited 1 time in total.
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
although feyd is correct, you should think about a design change, there is a way to do this:
curl()
and if you have questions with curl you can just search this forum because you will be able to find a lot of things about curl on this forum
edit: since its to another servers form then curl is going to be your best friend. read about it and learn to love it. post more questions if need be
curl()
and if you have questions with curl you can just search this forum because you will be able to find a lot of things about curl on this forum
edit: since its to another servers form then curl is going to be your best friend. read about it and learn to love it. post more questions if need be
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
You can do a post without curl...
Code: Select all
function post($host, $path, $data) {
$http_response = "";
$content_length = strlen($data);
$fp = fsockopen($host, 80);
fputs($fp, "post $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-Length: $content_length\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);
while (!feof($fp)) {
$http_response .= fgets($fp, 28);
}
fclose($fp);
return $http_response;
}
$postdata = "?var1=" . urlencode($var1) . "&var2=" . urlencode($var2);
$http_response = post('anotherServer.com', '/path/to/script.php', $postdata);- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
shoeboppa:
using that function, would this be proper format?
(the variables are defined in the script earlier...)
is that correct?
... first I get:
Warning: fsockopen(): unable to connect to http://login.myspace.com/:80 in...
then fputs(): supplied argument is not a valid stream resource in...
but that's probably because of the 1st one...
using that function, would this be proper format?
Code: Select all
$postdata = "&email=" . urlencode($email) . "&password=" . urlencode($password) . "&MyToken=" . urlencode($MyToken);
$http_response = post('http://login.myspace.com/', 'index.cfm?fuseaction=login.process', $postdata);is that correct?
... first I get:
Warning: fsockopen(): unable to connect to http://login.myspace.com/:80 in...
then fputs(): supplied argument is not a valid stream resource in...
but that's probably because of the 1st one...
Last edited by MinDFreeZ on Sat Feb 25, 2006 11:53 pm, edited 2 times in total.
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
If you are trying to acces MySpace and it is blocked you can access it from a proxy server.
http://www.proxyguy.com
http://www.proxyfoxy.com
haha, "The URL is:http://www.proxyguy.com/nph-proxy.cgi/0 ... roxy/start
The category of this URL is:Proxy Avoidance"
the proxies are blocked too.. i have no problem with getting to pages i want to..... I just want to manually submit and login to myspace (not from work, from home).. for.. other reasons.
The category of this URL is:Proxy Avoidance"
the proxies are blocked too.. i have no problem with getting to pages i want to..... I just want to manually submit and login to myspace (not from work, from home).. for.. other reasons.