Apparently i try to save the data into the mysql, but it didnt work.. Anyone help?
create_users.php
<script type="text/javascript">
var mac = macs.getMacAddress();
$.get('/create_users.php?mac=' + mac, function() { alert('yeah done'); })
</script>
checkAvailability.php
$mac = $_GET['mac'];
$mac = mysql_real_escape_string($mac);
$sql = "INSERT INTO test(mac) VALUES ('$mac')";
mysql_query($sql);
php grabbing data from javascript
Moderator: General Moderators
-
kennedysee
- Forum Newbie
- Posts: 14
- Joined: Fri Dec 04, 2009 12:17 am
Re: php grabbing data from javascript
The file name is different/wrong...
-
kennedysee
- Forum Newbie
- Posts: 14
- Joined: Fri Dec 04, 2009 12:17 am
Re: php grabbing data from javascript
Manage to get it change.... it only works when i manually called up from the browser...
http://localhost/checkAvailability.php?mac=555
create_users.php
checkAvailability.php
http://localhost/checkAvailability.php?mac=555
create_users.php
Code: Select all
<form method="post" action="checkAvailability.php">
<script type="text/javascript">
var macs = {
getMacAddress : function()
{
document.macaddressapplet.setSep( "-" );
return (document.macaddressapplet.getMacAddress());
}
}
</script>
<script type="text/javascript">
var mac = macs.getMacAddress();
$.get('/createAvailability.php?mac=' + mac, function() { alert('yeah done'); })
</script>
</form>Code: Select all
$dbhost = 'localhost';
$dbuser = 'root';
$dbname = 'registration';
mysql_connect($dbhost, $dbuser);
mysql_select_db($dbname);
$mac = $_GET['mac'];
$mac = mysql_real_escape_string($mac);
$sql = "INSERT INTO test(mac) VALUES ('$mac')";
mysql_query($sql);
echo mysql_error();