Hallo,
ich will wie bereits oben erwähnt Datenbank Einträge via Code ändern . Zum beispiel ein User möchte seine E-mail Adresse ändern usw.
Leider klappt es nicht wie gewünscht . Fehlercode Fatal error: Uncaught Error: Cannot use object of type mysqli as array
ich will wie bereits oben erwähnt Datenbank Einträge via Code ändern . Zum beispiel ein User möchte seine E-mail Adresse ändern usw.
Leider klappt es nicht wie gewünscht . Fehlercode Fatal error: Uncaught Error: Cannot use object of type mysqli as array
PHP-Code:
<?php include("top.php");?>
<?php include("connect.php");?>
<?php include("mysql.php");?>
<?php if(isset($_SESSION['email']))
{?>
<?php include("navigate.php");?>
<?php
$db = new mysqli('localhost', 'root', '', 'toksop');
?>
<div id="startseite">
<form action='' method='POST'>
<table cellspacing='10'>
<tr>
<td><b>Hobbys ändern:</b></td>
<td><input type='text' id='email' name='hobby'></td>
</tr>
<td></td><br>
<td><input type='submit' name='hobby_change' class='myButton' value='Registrieren' ></td>
</table>
</form>
</div>
<?php
$name = $db['username'];
$nachname = $db['nachname'];
$passwort = $db['passwort'];
$email = $db['email'];
$hobby = $db['hobbys'];
$email = $_POST['email'];
$passwort = $_POST['passwort'];
$passwort2 = $_POST['passwort2'];
$hobby = @$_POST['hobby'];
if ( isset($_POST['hobby_change']))
{
include('connect.php');
$abfrage = mysqli_query($db,"SELECT * FROM user WHERE id = 1");
$numrows = mysqli_num_rows($abfrage);
if($numrows ==0){
mysqli_query($db,"UPDATE user Set(username = ".$name.",nachname = ".$nachname.", email = ".$email.", passwort = ".$passwort.", passwort2 = ".$passwort2.", hobbys = ".$hobby.")");
echo "<b><font color='Green'>Sie haben Ihre Hobbys erfolgreich geändert!</font></b>";
}
}
?>
<?php include("bottom.php");?>
<?php }
else
echo "<div id='nicht_login'><h1 >Du bist nicht angemeldet!</h1> <a href='index.php'><h1>Melde dich jetzt noch an!</a></h1></div>";
?>
Kommentar