I have a table that looks like this:
name surname username password role
student student student@csd.auth.gr student student
student2 student2 student2@csd.auth.gr student2 student
and I want to be able to edit a row in php. The values are taken from a html file like this:
Username
student2@csd.auth.gr <--This will be written in a text box
Password
student2 <--This will be written in a text box
Name
student2 <--This will be written in a text box
Surname
student2 <--This will be written in a text box
Role
student <--This will be written in a text box
My php file is:
<?php
$hostname = "localhost";
$database = "mydb";
$username = "myuser";
$password = "mypsw";
$link = mysql_connect( $hostname , $username , $password ) or
die("Prosoxi!Provlima stin sundesi me ton server : " . mysql_error());
mysql_select_db($database,$link);
mysql_query("UPDATE user
SET username = '".mysql_real_escape_string($_POST[nusername])."',
SET password = '".mysql_real_escape_string($_POST[npassword])."',
SET name = '".mysql_real_escape_string($_POST[nname])."',
SET surname = '".mysql_real_escape_string($_POST[nsurname])."',
SET role = '".mysql_real_escape_string($_POST[nrole])."'
WHERE username='".mysql_real_escape_string($_POST[us])."'");
mysql_close($link);
header("Location: users.php");
?>
1.The update does not happen, so there's something wrong in the php file, that I can't find.
2. How can I achieve already filled boxes in the html file, with the right values, if I choose a certain username?
Can someone help me? Thank you in advance. :)