<html> <head></head> <link rel="stylesheet" type="text/css" href="style.css"
<body> <?php
$db = mysqli_connect('localhost', 'root', '', 'formdb');
$formId = '';
$LastName = '';
$FirstName = '';
$Email = '';
$Birthday = '';
$Birthplace = '';
$Comment = '';
if (isset($_GET['upd'])){
$formId = $_GET['upd'];
$results = mysqli_query($db, "SELECT * FROM tbl_form WHERE formId=$formId");
}
if(isset($_POST['submit']))
{
$formId = $_POST['formId'];
$LastName = $_POST['LastName'];
$FirstName = $_POST['FirstName'];
$Email = $_POST['Email'];
$Birthday = $_POST['Birthday'];
$Birthplace = $_POST['Birthplace'];
$Comment = $_POST['Comment'];
$query = "UPDATE tbl_form SET LastName='$LastName', FirstName='$FirstName', Email='$Email', Birthday='$Birthday', Birtplace='$Birthplace', Comment='$Comment' WHERE formId='$formId'";
mysqli_query($db, $query);
$_SESSION['msg'] = "Successfully Updated!";
header('location: form.php'); //redirect after inserting
}
?> <?php while($row = mysqli_fetch_array($results))
{ ?>
<form method="post">
<input type="hidden" name="formId" value="<?php echo $formId; ?>">
<div class="input-group">
<label> Last Name: </label> <input type="text" name="LastName" value="<?php echo $row['LastName']; ?>"> </div>
<div class="input-group">
<label> First Name: </label> <input type="text" name="FirstName" value="<?php echo $row['FirstName']; ?>">
</div>
<div class="input-group">
<label> Email: </label> <input type="text" name="Email" value="<?php echo $row['Email']; ?>"> </div>
<div class="input-group">
<label> Birtday </label>
<input type="date" name="Birthday" value="<?php echo $row['Birthday']; ?>">
</div>
<div class="input-group">
<label> Birthplace </label> <input type="text" name="Birthplace" value="<?php echo $row['Birthplace']; ?>">
</div> <div class="input-group">
<label> Comment </label>
<textarea type="text" name="Comment" value="<?php echo $row['Comment']; ?>">
</div>
<button type="submit" name="submit" class="btn" >Submit</button>
</form>
<?php } ?>
</body>
</html>
Charles_38 0 Newbie Poster
benanamen 69 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.