开发者

php grabbing data from javascript

开发者 https://www.devze.com 2022-12-17 20:08 出处:网络
Apparently i try to save the data into the mysql, but it didnt work.. Anyone help? create_users.php <form method=\"post\" action=\"checkAvailability.php\">

Apparently i try to save the data into the mysql, but it didnt work.. Anyone help?

create_users.php

<form method="post" action="checkAvailability.php">
 <script>
    var macs = { 
    g开发者_Python百科etMacAddress : 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

$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"..

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'); })
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号