Hi, I've been working on a site that sends data with jQuery Ajax to a url: profile.php
I'm having some trouble retrieving this data on the PHP page, profile.php
Here is profile.php (the part that is not working)
PHP Code:
$previouschoice = $_POST['data'];
if ($previouschoice == 'blueBGhas: "yes"')
{
$superSTRsql = "UPDATE Customize SET BlueBGhas='yes' WHERE Username = '$username'";
$superSTRsql1 = "UPDATE Customize SET YellowBGhas='no' WHERE Username = '$username'";
$superSTRsql2 = "UPDATE Customize SET GreenBGhas='no' WHERE Username = '$username'";
$superSTRsql3 = "UPDATE Customize SET RedBGhas='no' WHERE Username = '$username'";
$superSTRsql4 = "UPDATE Customize SET PurpleBGhas='no' WHERE Username = '$username'";
$superSTRsql5 = "UPDATE Customize SET BlackBGhas='no' WHERE Username = '$username'";
mysql_query($superSTRsql, $connection);
mysql_query($superSTRsql1, $connection);
mysql_query($superSTRsql2, $connection);
mysql_query($superSTRsql3, $connection);
mysql_query($superSTRsql4, $connection);
mysql_query($superSTRsql5, $connection);
}
else if ($previouschoice == 'greenBGhas: "yes"')
{
$superSTRsql = "UPDATE Customize SET BlueBGhas='no' WHERE Username = '$username'";
$superSTRsql1 = "UPDATE Customize SET YellowBGhas='no' WHERE Username = '$username'";
$superSTRsql2 = "UPDATE Customize SET GreenBGhas='yes' WHERE Username = '$username'";
$superSTRsql3 = "UPDATE Customize SET RedBGhas='no' WHERE Username = '$username'";
$superSTRsql4 = "UPDATE Customize SET PurpleBGhas='no' WHERE Username = '$username'";
$superSTRsql5 = "UPDATE Customize SET BlackBGhas='no' WHERE Username = '$username'";
mysql_query($superSTRsql, $connection);
mysql_query($superSTRsql1, $connection);
mysql_query($superSTRsql2, $connection);
mysql_query($superSTRsql3, $connection);
mysql_query($superSTRsql4, $connection);
mysql_query($superSTRsql5, $connection);
}
//Another few lines later...
if ($blueBGhas == 'yes')
{
echo '<style>body { background: blue; }</style>';
}
else if ($greenBGhas == 'yes')
{
echo '<style>body { background: green; }</style>';
}
Just to make sure, here is my jQuery Ajax code:
Code:
//AJAX STUFF
$(document).ready(function()
{
$('#bluebgradio').click(function()
{
$.ajax(
{
type: "POST",
url: "profile.php",
data: {blueBGhas: "yes"}
});
});
$('#greenbgradio').click(function()
{
$.ajax(
{
type: "POST",
url: "profile.php",
data: {greenBGhas: "yes"}
});
});
});