in my html i have:
<form method = "post" action = "creablog.php">
<p id = "titolosfondo"> Sfondo </p>
<select id = "sfondo" name = "sfondo" >
<option hidden></option>
<option value = "green"> Verde </option>
<option value = "blue"> Blu </option>
<option value = "red"> Rosso </option>
</select></br>
<input type = "submit" id = "crea" name = "crea" value = "Crea Blog" />
</form>
I have a form, where inside there is a SELECT OPTION, where I can select a color. When I click the button I would like the background color to be saved on another page.
i made this function in jquery:
$(document).ready(function(){
function cambiosfondo()
{
var x = document.getElementById("sfondo");
var bgcolor = x.options[x.selectedIndex].value;
document.body.style.backgroundColor = bgcolor;
}
});
in the database I have a table called BLOG where I have the SFONDO attribute. this is the query I use in the CREA BLOG page to insert the data.
$query2 = "INSERT INTO blog (titoloBlog,nomeSottotema,nomeUtente,sfondo, font, colorefont) VALUES ('$titoloblog','$sottotema',(SELECT nomeUtente FROM utentiregistrati WHERE nomeUtente = '$nomeutente'),'$sfondo','$font','$colore');";
$result2 = mysqli_query($mysqli, $query2);
if(!$result2){
echo 'errore 2';
} else {
header("Location: blog.php?blog=$titoloblog");
}
this is the query I use on the BLOG page to get the data. The BLOG page is the page where I want the background to change color.
$blog = $_GET['blog'];
$query = "SELECT * FROM `blog` WHERE titoloBlog = '$blog'";
$result = mysqli_query($mysqli, $query);
if(!$result){
echo 'errore';
}
no error appears. the INSERT query executes successfully. But there is no background change on the BLOG page. please help me!