html - Submit PHP Variables to Another Domain -
i'm trying submit url website website (we'll call domain b) php variables included in url.
when hit submit button on php form need create url in following syntax:
http://domainb.com/submissions.cfm?name=phpvariable1&name2=phpvariable2
what's best way this?
it's basic html
<form method="get" action="http://domainb.com/submissions.cfm"> <input name="test1" type="text" value="aaa" /> <input name="test2" type="text" value="bbb" /> <input type="submit" value="send" /> </form>
the url when click http://domainb.com/submissions.cfm?test1=aaa&test2=bbb
you can use post action or more advanced way curl. moreover, there no "php form". forms displayed browser uses html it's called frontend, php cannot show forms because it's backend. browser doesn't care if php, ruby or own language. show page needs html that's all.
curl example post:
<?php $ch = curl_init('http://domainb.com/submissions.cfm'); $encoded = ''; $variables = array('test1' => 'aaa', 'test2' => 'bbb'); foreach($variables $name => $value) $encoded .= urlencode($name).'='.urlencode($value).'&'; $encoded = substr($encoded, 0, strlen($encoded)-1); //remove last ampersand curl_setopt($ch, curlopt_postfields, $encoded); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_post, 1); curl_exec($ch); curl_close($ch); ?>
Comments
Post a Comment