$indate = '2014-01-07';
echo '
<script language="JavaScript" src="http://code.jquery.com/jquery-latest.min.js">
var indate = \''.$indate.'\';
alert(indate);
}
</script> ';
<?php // RAY_temp_eict.php
error_reporting(E_ALL);
// CREATE A PHP VARIABLE
$indate = '2014-01-07';
// CREATE A RESPONSE DOCUMENT USING HEREDOC NOTATION
$document = <<<EOD
<script>
var indate = '$indate';
alert(indate);
</script>
EOD;
// SEND THE RESPONSE TO THE BROWSER
echo $document;
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
$("#signal").click(function(){
indata = $("#xinput").val();
$.post("add_agencyreferral_prepop.php", {myArg:indata}, function(response){
$("#output p#target").html(response);
});
});
});
</script>
$id = $_POST['myArg'];
$queryagency = "SELECT id, name, address1, address2, city, county, contactNo FROM agency WHERE id = '$id'";
$resultagency = @mysql_query ($queryagency); // Run the query.
$rowagency = mysql_fetch_array($resultagency, MYSQL_NUM);
// SEND THE CONTENTS OF THE OUTPUT BUFFER
die($rowagency[1]);
Else you would need to just Ajax to make a call to the server to check if the key exists.
Or using jQuery it would be even easier
The idea is that when the submit button is clicked you halt the form from being submitted, make a request to a php page on your server asking if the key exists. The page returns either 0 (doesn't exist) or 1 (does exist). At this point you either then let the page finish submitting or send an alert to the user and end the submit.