javascript variable inside php
Posted: Fri Mar 26, 2010 8:26 am
hi,
i have searched high and low and cannot find what i want. I understand the javascript is client side and php is server side. What i am trying to do is pass the javascript variable var url to the domainCheck($url) php function:
once i have the javascript value inside the php variable, i can pass it to the following domainCheck($url) php function:
Is this possible? If not, or if there is a better way to do what i am trying to achieve i would be very grateful to hear.
i have searched high and low and cannot find what i want. I understand the javascript is client side and php is server side. What i am trying to do is pass the javascript variable var url to the domainCheck($url) php function:
Code: Select all
<script language="javascript" type="text/javascript">
function passURL()
{
var url = document.getElementById('url').value;
alert ("<?php domainCheck("*[b]*want to get var url in here**[/b]") ?>");
}
</script>
Code: Select all
/***** start check domain availability *****/
<?php
function domainCheck($url)
{
$domain = $url;
$ch = curl_init();
$postData = "SessionID=" . $sessionID;
$postData .= "&" . "Type=Domains";
$postData .= "&" . "Object=Domain";
$postData .= "&" . "Action=Availability";
$postData .= "&" . "Domain=" . $domain;
curl_setopt($ch, CURLOPT_URL, "https://www.distributeit.com.au/api/query.pl");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
/**
* $result will contain:
* (Domain): OK: Minimum=(years)&Maximum=(years)
* OR
* (Domain): ERR: (Error Code),(Error Description)
**/
$result = curl_exec($ch);
/* you may want to check curl_error($ch); */
curl_close($ch);
/***** end check domain avaiability *****/
echo $result;
}
?>