Answer the question
In order to leave comments, you need to log in
How to take updated data from the database?
There is a color upgrade code
include ('../connect/config.php');
if (isset($_POST['update_color'])){
$id=$_SESSION['id'];
$site_color = $_POST['site_color'];
$sql = ("UPDATE users SET site_color='$site_color' WHERE id='$id'");
$query = mysql_query($sql);
if (!$query){
die('updating error'. mysql_error());
}
else { echo 1; }
}
header('Location: /');
Answer the question
In order to leave comments, you need to log in
I'm not a strong specialist in terms of code here, but ...
When executing update_color before querying the database (or after), force the user to reload the page (if it's not critical, which is long), or change the required block in CSS in the browser with Javascipt.
Your code is unsafe.
Imagine your code where $_POST['site_color'] = "123', username=(DELETE Users), id=1";
$site_color = $_POST['site_color'];
$sql = ("UPDATE users SET site_color='$site_color' WHERE id='$id'");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question