Skip to content

Instantly share code, notes, and snippets.

@trivoallan
Created September 13, 2011 13:04
Show Gist options
  • Select an option

  • Save trivoallan/1213762 to your computer and use it in GitHub Desktop.

Select an option

Save trivoallan/1213762 to your computer and use it in GitHub Desktop.
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
//document.chronoform_devis.getElementById('partmail').innerHTML = ajaxRequest.responseText;
alert('ok');
}
}
//var codepart = document.getElementById('codepart').value;
ajaxRequest.open("GET", "http://www.courtier-en-pret-immobilier.com/partenaires.php", true);
ajaxRequest.send(null);
}
<?php
$dbhost = "xxxx";
$dbuser = "xxxx";
$dbpass = "xxxx";
$dbname = "xxxx";
//Connect to MySQL Server
mysql_connect($dbhost, $dbuser, $dbpass);
//Select Database
mysql_select_db($dbname) or die(mysql_error());
// Retrieve data from Query String
$codepart = $_GET['codepart'];
// Escape User Input to help prevent SQL Injection
$codepart = mysql_real_escape_string($codepart);
//build query
$query = "SELECT partMail FROM partenaires WHERE codepart = '$codepart'";
if ($result=mysql_query($query)) {
$mailpart= mysql_num_rows($result);
} else {
$message = "<p><font color=\"red\"><b>Le code partenaires n'existe pas.<br /> ".$query."</b></font></p>";
}
echo $mailpart;
mysql_free_result($result);
mysql_close($db);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment