i have created a form to update name into database, i have created two tables first_name
and last_name
into database, have look once here is my code:
$sql="
CREATE TABLE admin
(
id INT PRIMARY KEY AUTO_INCREMENT,
first_name VARCHAR(100),
last_name VARCHAR(100),
)";
Now i have created to update form here:
<div class="box">
<h1 style="font-family: consolas">Change your name</h1><hr>
<div id="change_name">
<label><strong>Your current name: </strong></label>
<?php
include('change_setting_db.php');
while($row = mysqli_fetch_array($result))
{
echo $row['first_name']." ".$row['last_name'];
}
?><br><br>
<form method="post" action="do_update_name.php">
<label><strong>First name: </strong></label>
<input type="text" name="first_name">
<label><strong>Last name: </strong></label>
<input type="text" name="last_name">
<input type="submit" value="Submit">
</form>
</div>
</div>
and here is my do_update_name.php
file:
<?php
$firstname=$_POST['first_name'];
$lastname=$_POST['last_name'];
$id=$_GET['id'];
$con=mysqli_connect("localhost","root","Bhawanku", "members");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$update =mysqli_query($con,"UPDATE admin SET first_name='$firstname' AND last_name='$lastname' WHERE id='$id' ");
if($update){
echo "Successfully created!!";
}
?>
Now problem is when i put new name and do submit, it shows an error:
Notice: Undefined index: id in C:\Users\Raj\PhpstormProjects\...
ew do_update_name.php on line 4
Successfully created!!