In this code there is one input field which is used for update data. data is updating perfectly. but i want to show the previous data in my input field when i will click 'Add' button. So that when i click add button i can see my previous data in the input field and then i can update.
I want to show biotext in the input field from database when I update data. i used $biotext in the input field.
but the previous data is not showed.The input field shows ->
Notice: Undefined variable: biotext in /Applications/XAMPP/xamppfiles/htdocs/Social/edit.php on line 76
I don't know what is the problem.
please help me to find out the problem.
thanks in advance.
<?php
// edit bio
// edit bio
if(isset($_GET['edit_id']) && !empty($_GET['edit_id']))
{
$id = $_GET['edit_id'];
$stmt= $db->select('SELECT biotext FROM bio WHERE userid =:userid',array('userid'=>$id));
}
if(isset($_POST['update']))
{
$userid = $_SESSION['userid'];
$biotext = $_POST['biotext'];
if(empty($biotext))
{
$errMSG = "Please update your bio.";
}
else
{
$user_bio = $db->update("UPDATE bio SET biotext=:biotext WHERE userid=:userid",array('biotext'=>$biotext,'userid'=>$userid));
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
if(isset($_GET['edit_id']) && !empty($_GET['edit_id']))
{
?>
<div class="row main-row">
<div class="col-md-11 ">
<?php
if(isset($errMSG))
{
echo $errMSG;
}
?>
<form method="post" name="form1" action="edit.php">
<table width="25%" border="0">
<tr>
<td>Add your bio</td>
<td><input type="text" name="biotext" value="<?php echo $biotext; ?>"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="update" value="Add"></td>
</tr>
</table>
</form>
</div>
</div>
<?php
}
// edit bio
// edit bio
?>
</div>