I have a php file which contains the following code:
function render() {
//fetches all the data from input.
$date = date("Y-m-d H:i:s");
$con = mysql_connect("127.0.0.1","root","");
$database = mysql_select_db("guestbook");
$name = $_POST['name'];
$email = $_POST['email'];
$post = $_POST['post'];
$sql = "INSERT INTO gast(name, email, post, date) VALUES('$name','$email','$post','$date')";
$input = mysql_query($sql);
mysql_close($con);
}
With javascript, I'd like to retrieve those variables, something like this:
document.getElementById('button').onclick = clicked;
function clicked() {
var name = document.render.name.value;
var post = document.render.post.value;
var email = document.render.email.value;
}
I have included that javascript code in my body, but it doesn't work. How do I get the value?