hi everybody,
i encounter a problem regarding PHP when i am doing my internship.
i have a javascript which looks like this.
<Script Language = "JavaScript">
function sent()
{
var text1, fTxt,dT;
text1 = document.form1.EPTextField.value;
dT = new Date();
fTxt =("You entered" + ": " + text1 + " " + ":" + dT);
document.form1.EPText.value = fTxt;
}
</script>
where it will be called by onClick of a button
<input type="button" name="EPButton" id="EPButton" value="Send" onClick = "sent()"/>
However i need to save the fTxt into a database MySQL. my in charge called me to use php.
$con = mysql_connect("localhost","host"); //connect database
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("chat",$con); //select database
mysql_query("INSERT INTO chat (Name, Date, Content, Time)
VALUES ('fTxt')"); //insert
mysql_close($con);
?>
BUT here is the problem, my supervisor says that php doesn't understand what is the javascript value. so i need a platform like AJAX; i saw the ajax tutorial, i totally can't get it into my mind. so is there another way i can get it to work? or perhaps i can change the javascript function into a php function. but i tried googling "how to declare a var as a textbox value in php" and didnt get what VAULT said. I hope i can get some help here.