html - Database won't update values with php form -
i trying make small form can update value database, won't work.. i've read different questions , answers on topic can't manage work.
here's code:
<?php include_once("php_includes/check_login_status.php"); $u = ""; $country = ""; if(isset($_get["u"])){ $u = preg_replace('#[^a-z0-9]#i', '', $_get['u']); } else { header("location: index.html"); exit(); } //a lot of other code other queries $sql = "select * users username='$u' , activated='1'"; $user_query = mysqli_query($db_conx, $sql); mysqli_query($db_conx,"update set country='$_post[country]' username='$_post[u]' "); if($result){ echo "succesful"; } else { echo "error"; } ?> <form method="post" /> <p><span>country: </span><input type="text" name="country" id="country" value="<?php echo $country; ?>"></p> <p><input class="submit" name="submit"type="submit" value="save"> </form>
anyone can see what's wrong code? thanks!
$country = $_post['country']; mysqli_query($db_conx,"update users set country='$country' username='$u' ");
you did not mention table in update statement. , $_post
name must quoted in []
.
Comments
Post a Comment