-1

I tried to create a Html/Php page to Update sql records but... for some reason, i get

Notice: Undefined index: Producent in C:\xampp\htdocs\sql\sqlupdate.php on line 15

Produkt er opdateret

i have 3 files for this procedure

Rediger.html

<html>

<body>
<h1>Slet produkt</h1>
<form action="sqlrediger.php" method="post">
Skriv ID på det produkt du vil redigere: <input type="text" name="id" /><br>    <br>


<input type="submit" />
</form>
</body>
</html>

sqlrediger.php

<?php
@$con = mysql_connect( 'localhost', 'root', '' );
if( !$con ) {
die( 'Could not connect: ' . mysql_error() );
} else {
mysql_select_db( 'headsets', $con );
$result = mysql_query( "SELECT * FROM modeller WHERE id ='{$_POST["id"]}'"    );
while( $row = mysql_fetch_array( $result ) ) {
    ?>
    <form action="sqlupdate.php" method="post">
    <fieldset>
    <legend><h1>Rediger produkt</h1></legend>

    <form>
        <input name="ID" type="text" value="<?php echo( htmlspecialchars( $row['ID'] ) ); ?>" />
    </form>
    <form>
        <input name="Producent" type="text" value="<?php echo( htmlspecialchars( $row['Producent'] ) ); ?>" />
    </form>

    <input type="submit" />

    </fieldset>


    <?php
}
}



?>

sqlupdate.php

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "headsets";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} 

$sql="UPDATE modeller SET Producent = ('$_POST[Producent]') WHERE ID =    ('$_POST[ID]')";

if ($conn->query($sql) === TRUE) {
echo "Produkt er opdateret";

} else {
echo "Error: " . $sql . "<br>" . $conn->error;

}




$conn->close();

?>
Djsvell
  • 1
  • 3

1 Answers1

0
$sql="UPDATE modeller SET Producent = '".$_POST['Producent']."' WHERE ID =    '".$_POST['ID']."'";

Try this for line 15. I've fixed some quotes here and there.

Werner
  • 449
  • 4
  • 12