Hello,
I thought this bit of Ajax was working perfectly.
However, I just discovered that the mysql query in div ID "highslide-html-contactform1" gets executed without being clicked as long as the user is logged in (that is, if($my->id) is true).
Is there any way to limit execution to only the "onclick" event.
$result=mysql_query($query1) or die(mysql_error());
$query2 = "select supplierName from vendor where supplierid = $vendorid";
$res2=mysql_query ($query2) or die(mysql_error());
while($row=mysql_fetch_array($res2)){
$vendornamename=$row["supplierName"];
}
echo "Thank You for your request " . $my->name ." (" . $my->username . ").<br>";
echo"<br>Your request for information has been submitted to $vendornamename";
}
else{
echo"You must first log in (or register) in order to request information <BR>Use your login on the right. No Account? <a href=\\">
Register Now.</a>";
}
There is not really enough information/code posted to fully grasp your problem. It sounds to me as though you have your PHP and HTML all in the same file. Well, naturally the server with execute the PHP first. So, I would suggest making two separate files. One should be the HTML file. Then other should be the PHP script called by the AJAX. Then the onclick event would be easy to call.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Which is why I suggested that you split them into two files. Or, you need to start using isset() with session variables to see if the user is already logged in.
PHP Code:
if (isset($_SESSION['user'])) {
// user must be logged in
// run script accordingly
}
else {
// user is not logged in
// make login happen
}
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Bookmarks