Im new to PHP and MySQLi so I hope someone can help me.
I want to make a page where I can update info from my database using a form.
This is my PHP codes:
<?php
// Create connection
require_once "configuration.php";
$Conf = new JConfig;
$conn = mysqli_connect($Conf->host, $Conf->user, $Conf->password, $Conf->db);
// Create connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>
<?
$result = mysqli_query($conn, $sql);
error_reporting(E_ALL);
ini_set('display_errors', 1);
$id = $_GET['id'];
?>
<?php
// php code to Update data from mysql database Table
if(isset($_POST['update']))
{
// get values form input text and number
$int_bemerkning = $_POST['int_bemerkning'];
$navn = $_POST['navn'];
// mysql query to Update data
$query = "UPDATE `dykkerkurser_owd` SET `int_bemerkning`='".$int_bemerkning."',`navn`='".$navn."' WHERE `id`='" . $id . "'";
$result = mysqli_query($connect, $query);
if($result)
{
echo 'Data Updated';
}else{
echo 'Data Not Updated';
}
mysqli_close($connect);
}
?>
and my form looks like this:
<form action="#" method="post">
bemerkning:<input type="text" name="int_bemerkning" value="<?php echo $int_bemerkning; ?>" ><br><br>
navn:<input type="text" name="navn" value="<?php echo $navn; ?>" ><br><br>
<input type="submit" name="update" value="Update Data">
</form>
So Issue is: 1. the form above dont show what is saved in the database using
value="<?php echo $navn; ?>"
and 2. I can not update any info.
Can some one see what im doing wrong?