我想通過他的ID從數據庫打印用戶名。我希望通過將其輸入到輸入表單來選擇id,但它不起作用。任何線索爲什麼?通過從MySQL打印用戶名通過php
<div>
<p><u>Anzeigen eines Users mit Eingebafeld für die id</u></p>
<form method="post1" >
<p>Zu suchende id:</p> <input type="text" name="id" class="form-control"><br>
<input type="submit" name="Buttonid" value="Suchen" class="btn btn-primary" >
</form>
</div>
<div>
<?php
/*ini_set('display_errors', 0);*/
$mysqli = new mysqli("localhost", "test", "test", "test");
if ($mysqli->connect_errno) {
print "Failed to connect to MySQL: " . $mysqli->connect_error;
}
$id = @$_POST1;
$res = $mysqli->query("SELECT username FROM user WHERE id = $id");
$row = $res->fetch_assoc();
print '<p>' . $row['username'] .'</p>';
?>
</div>
</div>
在'
你能指定你的意思嗎? – Pingbeat
''form method =「post1」>'應該是''form method =「POST」>'和'$ id = @ $ _ POST1;'應該是'$ id = $ _POST ['id'];' – Qirel