[英]php grabbing data from javascript
Apparently i try to save the data into the mysql, but it didnt work.. Anyone help? 显然我尝试将数据保存到mysql中,但没有成功。有人帮忙吗?
create_users.php create_users.php
<form method="post" action="checkAvailability.php">
<script>
var macs = {
getMacAddress : function()
{
document.macaddressapplet.setSep( "-" );
return (document.macaddressapplet.getMacAddress());
}}jQuery(document).ready(function(){
var mac = macs.getMacAddress();
$.get('/checkAvailability.php?mac=' + mac, function() { alert('yeah done'); })
});
</script>
<script type="text/javascript">
document.write(macs.getMacAddress());
</script>
</form>
checkAvailability.php checkAvailability.php
$dbhost = 'localhost';
$dbuser = 'root';
$dbname = 'registration';
mysql_connect($dbhost, $dbuser) or die("Could not connect database");
mysql_select_db($dbname);
$mac = $_GET['mac'];
$mac = mysql_real_escape_string($mac);
$sql = "INSERT INTO test(mac) VALUES ('$mac')";
mysql_query($sql);
You are calling "create_users.php" in your $.get() method instead you should be calling "checkAvailability.php".. 您在$ .get()方法中调用“ create_users.php”,而不是在调用“ checkAvailability.php”。
And try this for your client side form: 并尝试将其用于您的客户端表单:
var macs = {
getMacAddress : function()
{
document.macaddressapplet.setSep( "-" );
return (document.macaddressapplet.getMacAddress());
}}jQuery(document).ready(function(){
var mac = macs.getMacAddress();
$.get('/checkAvailability.php?mac=' + mac, function() { alert('yeah done'); })
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.