Ok. So here’s what I want to do.
I would like to make it so that a piece of code, grabs the contents form the variable
$_SESSION['user']
and find the row in the MySQL table the contains that variable.
Then I want it to edit a row that already has information in it by grabbing information from another variable such as
$_POST['country']
I have no idea how to do this. Is there a simple way.
The MySQL info is:
host: 'localhost'
user: 'root'
pass: ''
db: 'database'
table: 'accounts'
You can do it something like this:
Just replace the field/table with their respective names.
The actual SQL you’re learning here is:
Make sure to always sanitize the input as done with mysql_real_escape_string; Not doing this leaves a hole in your system which is very easy to exploit – and at worst costs you your database to be dropped, sensitive data to be exposed or a hacker to succesfully authorize himself as another user.
And if you havn’t connected to the database, you do this (before running the query):