Je suis en train d'utiliser POST pour passer des variables à chat.php de try.htm
Le code pour try.htm est:
<head>
<script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type = "text/javascript">
function yo() {
var text = $("#msg").val();
$.post("chat.php",msg:text);
}
</script>
</head>
<body>
<input type="text" id="msg" onkeyup="yo()">
<div id="display">Change</div>
</body>
Le code pour chat.php est:
<?php
$msg=$_POST['msg'];
mysql_connect("localhost","root");
mysql_select_db("user");
mysql_query("INSERT INTO user (name,pwd,status) VALUES ('$msg','work','0')") or die(mysql_error());
?>
Le problème est que la variable 'msg' ne semble pas être passée sur chat.php! Qu'est-ce qui ne va pas?
En fait, vous devriez obtenir une erreur de syntaxe/analyse. –