我希望该用户通过其用户ID更新自己的数据。我不希望它会在网址中显示,所以我试着这样做:
<?php
session_start();
if (isset($_SESSION['id'])){
$userId = $_SESSION['id'];
}
else {
header('Location: login_sys.php');
die();
}
include_once('/var/www/html/private/db_credentials.php');
$db = mysql_connect ("$servername", "$username", "$password", "$dbname") or die("Kann nicht mit DB verbinden.!");
//Wenn eingegeben
if (isset ($_POST['submit'])) {
$betrieb = $_POST['betrieb'];
$anschrift = $_POST['ort'];
$apartner = $_POST['apartner'];
$praktika = $_POST['praktika'];
//Was wurde eingegeben
//
$query = "UPDATE nutzer SET betrieb='$betrieb', ort='$ort', apartner='$apartner', praktika='$praktika' WHERE id='$userId' ";
mysqli_query($db, $query, $sql);
}
?>
以下是表格:
<form action="bearbeitung_checker.php" method="POST">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="sample3" name="betrieb">
<label class="mdl-textfield__label" for="sample3">Betrieb...</label>
</div>
<!-- Textfield with Floating Label -->
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="sample3" name="ort">
<label class="mdl-textfield__label" for="sample3">Anschrift...</label>
</div>
<!-- Textfield with Floating Label -->
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="sample3" name="apartner">
<label class="mdl-textfield__label" for="sample3">Ansprech Partner...</label>
</div>
<!-- Textfield with Floating Label -->
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="sample3" name="praktika">
<label class="mdl-textfield__label" for="sample3">Praktika...</label>
</div>
<a></a><br>
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" type="submit" id="submit" name="submit">
Bearbeitung speichern
</button>
</form>
我不知道我在这里做错了什么,因为我没有得到500错误。
如果你能帮助我,我会很高兴。
亲切的问候,
Yan Malinovskiy