Somebody can help me, why isnt working this code ?
<form action="" method="post">
Firstname:<input type="text" id ="changefirstnamebox" name="firstname " maxlength="20">
Lastname: <input type="text" id ="changefirstnamebox" name="lastname" maxlength="20">
<center>
<input type="submit" id ="changeusernamebutton" name="changeusernamebutton" value="Change">
</center>
</form>
<?php
$con=mysqli_connect("localhost","root","","user_registration");
if(isset($_POST["changeusernamebutton"])){
echo "working";
if(!empty($_POST['firstname']) && !empty ($_POST['lastname'])) {
$newfirstname=mysqli_real_escape_string($con,$_POST['firstname']);
$newlastname=mysqli_real_escape_string($con,$_POST['lastname']);
echo $newfirstname;echo $newlastname;
$sql ="UPDATE login SET firstname = '$newfirstname' WHERE ID=$dbid" or die ("cant update " . mysqli_error($con));
$result = mysqli_query($con,$sql) or die ("cant update" . mysqli_error($con));
if($result)
echo"working";
else{
echo"not working";
}
}
}
?>