Hi, Aurlito
Like dagon say, you should be add quotes around your connection parameters because with this syntax you induce PHP preprocessor is try to divide bargcom by @ and this is inregular erroneous.
About Ajax script.
You don't have open bracket after javascript function
function newtrl()
, this must be
function newtrl() { ... function body ... }
In Ajax redirect URL "http://www.1barg.com/page.php?trl=", but it's always will be empty, because you don't catch any value of element, which it to assume. Тherefore you always go to ELSE case in your conditions:
if ($trl==1)
{
echo "$rand";
} // if user clicked the button below, generate a random string.
else
{
echo "$rand3";
}// for when page was opened.
So, to catch some element value and to put in Ajax url request you can do somthing like this :
......
$btnVal = document.getElementById("btn").value;
.....
HTML ....
<input type="button" value="New Troll" [B]id="btn"[/B] onclick="newtrl()"/>
So, when you get the values you can add it in some condition
alert(document.getElementById("btn").value);
if( document.getElementById("btn").value == 'New Troll') {
xmlhttp.open("GET","http://localhost?trl=1",true);
}else {
xmlhttp.open("GET","http://localhost?trl=0",true);
}
or put directly in some URL parameter
......
var btnVal = document.getElementById("btn").value;
.....
alert(btnVal );
xmlhttp.open("GET","http://localhost?trl="+btnVal ,true);
I hope this helping you to figure out how to get and assume parameters and values in Ajax request.