i can't update my name into database it's giving an error:
Notice: Undefined index: first_name in C:\Users\Raj\PhpstormProjects\new linkvessel\change_name.php on line 178
Notice: Undefined index: last_name in C:\Users\Raj\PhpstormProjects\new linkvessel\change_name.php on line 178
I have created two column for first_name
and last_name
into database please where i'm doing wrong? help please
here is my code:
<body>
<div id="left_box"><br>
<img src="Images/general_setting.png" height="18" width="18"><a href="general_settings.php" style="text-decoration: none; color: #000000; font-family: Arial";> General</a><br><br>
<img src="Images/photo_setting.png" height="18" width="18"><a href="photo_settings.php" style="text-decoration: none; color: #000000; font-family: Arial";> Photos</a><br><br>
</div>
<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>
<label><strong>First name: </strong></label>
<input type="text" name="first_name">
<label><strong>Last name: </strong></label>
<input type="text" name="last_name">
</form>
<?php
$con=mysqli_connect("localhost","root","Bhawanku", "members");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM admin");
while($row = mysqli_fetch_array($result))
{
}
mysqli_query($con,"UPDATE admin SET first_name='$_POST[first_name]' AND last_name='$_POST[last_name]' WHERE id='$row[id]' ");
mysqli_close($con);
?>
</div>
</div>
</body>
EDITED
full source code: http://pastebin.com/TparWavH