我有2页;我的索引和我的帐户细节。我的索引页面上有一个名为" Account"的按钮。点击它进入accountdetails页面。但是,它并没有将用户的信息转换为表格。我该怎么做?
索引
<?php
session_start();
$dbhost = "localhost";
$dbuser = "pc4u0fi_username";
$dbpass = "pc4upc4u1";
$dbname = "pc4u0fi_pc4u";
// Create connection
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query = "SELECT * FROM Klanten WHERE ID = '".$_GET['wijzigen_id']."'";
$result = $conn->query($query);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>PC4U</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"> </script>
<link href="index.css" rel="stylesheet">
</head>
<script>
function myFunction() {
alert("U bent succesvol uitgelogd");
}
</script>
<body>
<div id="container1">
<header>
<div id="headerFotoDiv">
<img src="images/logo.jpg" height="100px" class="lihover"
onclick="window.location='http://www.pc4u.hexodo.nl/'">
</div>
<?php
if ($_SESSION['ingelogd']) {
?>
<div id="headerLogindiv">
<button class="btn btn-warning" onclick='location.href="?p=ac?wijzigen_id=<?= $row['ID'] ?>"'
style="width: 130px; height:30px; margin-left: 160px; margin-top: 12px; text-align: center;">Account
</button>
<button class="btn btn-warning" onclick="window.location='?p=lo'"
style="width: 130px; height:30px; margin-left: 160px; margin-top: 12px; text-align: center;">
Uitloggen
</button>
</div>
<?php
} else {
?>
<div id="headerLogindiv">
<button class="btn btn-warning" onclick="window.location='?p=i'"
style="width: 130px; height:30px; margin-left: 160px; margin-top: 12px; text-align: center;">
Inloggen
</button>
<button class="btn btn-warning" onclick="window.location='?p=re'"
style="width: 130px; height:30px; margin-left: 160px; margin-top: 15px; text-align: center;">
Registreren
</button>
</div>
<?php
}
?>
</header>
<!-- Static navbar -->
<nav class="navbar navbar-default"
style="width: 1000px; margin-bottom:0px;padding-bottom:0px;padding-top:0px;border:0px;border-bottom:1px solid #000;border-radius:0px; background-color:#FFFFFF;"
;>
<div class="container-fluid" style="padding:0px;">
<div id="navbar" class="navbar-collapse collapse" aria-expanded="true" style="height: 1px;padding:0px;">
<ul class="nav navbar-nav">
<li onclick="document.location.href='http://www.pc4u.hexodo.nl/'" class="lihover"><a>Home</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">Computers
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="?p=dp">PC</a></li>
<li><a href="?p=lp">Laptop</a></li>
</ul>
</li>
<li><a href="?p=r">Reparatie</a></li>
<li><a href="?p=c">Contact</a></li>
<li><a href="?p=w">Winkelwagen</a></li>
</ul>
</div>
</div>
</nav>
<!-- Vulling van de pagina -->
<div id="vulling">
<?php
if (isset($_GET['p'])) {
$pagina = $_GET['p'];
switch ($pagina) {
case "c":
include("contact.php");
break;
case "r":
include("reparatie.php");
break;
case "re":
include("registreren.php");
break;
case "i":
include("inloggen.php");
break;
case "w":
include("shoppingcart.php");
break;
case "ch":
include("computerhome.php");
break;
case "lp":
include("laptop.php");
break;
case "lo":
include("logoutfrontend.php");
break;
case "ac":
include("accountDetails.php");
break;
case "dp":
include("desktop.php");
break;
default:
include("home.php");
break;
}
} else {
include("home.php");
}
?>
</div>
</div>
</body>
</html>
Accountdetails
<?php
$dbhost = "localhost";
$dbuser = "pc4u0fi_username";
$dbpass = "pc4upc4u1";
$dbname = "pc4u0fi_pc4u";
// Create connection
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$showalertsuccess = false;
$showalertdanger = false;
$retrieve = "SELECT * FROM Klanten WHERE ID = '".$_GET['wijzigen_id']."'";
$result = mysqli_query($conn, $retrieve);
$data = mysqli_fetch_assoc($result);
$minion = $_GET['wijzigen_id'];
if(isset($_POST['submit']))
{
$voornaam = $_POST['voornaam'];
$achternaam = $_POST['achternaam'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
$woonplaats = $_POST['woonplaats'];
$postcode = $_POST['postcode'];
$straat = $_POST['straat'];
$huisnr = $_POST['huisnr'];
$telnr = $_POST['telnr'];
$query = "UPDATE Klanten SET klant_voornaam='$voornaam', klant_achternaam='$achternaam', klant_email='$email', klant_username='$username', klant_wachtwoord='$password', klant_woonplaats='$woonplaats', klant_postcode='$postcode', klant_straat='$straat', klant_huisnr='$huisnr', klant_telefoonnnummer='$telnr' WHERE ID = '".$_GET['wijzigen_id']."'";
}
?>
<h1 style="margin-left: 10px;">Uw gegevens</h1><br>
<form class="form-horizontal" role="form" method="post">
<div class="form-group">
<label class="control-label col-sm-2" style="text-align: left; width: 120px; margin-left: 20px; margin-top: 10px;" for="vnaam">Voornaam:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="vnaam" value="<?=$data['klant_voornaam'];?>" name="vnaam" style="width: 250px; margin-top: 10px; margin-left: 40px;" required placeholder="">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="anaam" style="text-align: left; width: 120px; margin-left: 20px; margin-top: 10px;">Achternaam:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="anaam" value="<?=$data['klant_achternaam'];?>" name="anaam" style="width: 250px; margin-top: 10px; margin-left: 40px;" required placeholder="">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" style="text-align: left; width: 120px; margin-left: 20px; margin-top: 10px;" for="email">Email:</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" value="<?=$data['klant_email'];?>" name="email" style="width: 250px; margin-top: 10px; margin-left: 40px;" required placeholder="">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" style="text-align: left; width: 120px; margin-left: 20px; margin-top: 10px;" for="username">Username:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="username" value="<?=$data['klant_username'];?>" name="username" style="width: 250px; margin-top: 10px; margin-left: 40px;" required placeholder="">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" style="text-align: left; width: 120px; margin-left: 20px; margin-top: 10px;" for="wachtwoord">Wachtwoord:</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="wachtwoord" value="<?=$data['klant_wachtwoord'];?>" name="wachtwoord" style="width: 250px; margin-top: 10px; margin-left: 40px;" required placeholder="">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" style="text-align: left; width: 120px; margin-left: 20px; margin-top: 10px;" for="woonplaats">Woonplaats:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="woonplaats" value="<?=$data['klant_woonplaats'];?>" name="woonplaats" style="width: 250px; margin-top: 10px; margin-left: 40px;" required placeholder="">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="postcode" style="text-align: left; width: 120px; margin-left: 20px; margin-top: 10px;">Postcode:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="postcode" value="<?=$data['klant_postcode'];?>" name="postcode" style="width: 250px; margin-top: 10px; margin-left: 40px;" required placeholder="">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" style="text-align: left; width: 120px; margin-left: 20px; margin-top: 10px;" for="straat">Straat:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="straat" value="<?=$data['klant_straat'];?>" name="straat" style="width: 250px; margin-top: 10px; margin-left: 40px;" required placeholder="">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" style="text-align: left; width: 120px; margin-left: 20px; margin-top: 10px;" for="huisnr">Huisnummer:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="huisnr" value="<?=$data['klant_huisnr'];?>" name="huisnr" style="width: 250px; margin-top: 10px; margin-left: 40px;" required placeholder="">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" style="text-align: left; width: 120px; margin-left: 20px; margin-top: 10px;" for="telnr">Telefoonnummer:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="telnr" value="<?=$data['klant_telefoonnummer'];?>" name="telnr" style="width: 250px; margin-top: 10px; margin-left: 40px;" required placeholder="">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" style="margin-left: 170px; margin-bottom: 20px;" class="btn btn-default" name="submit">Wijzigen</button>
</div>
</div>
</form>
答案 0 :(得分:0)
我建议在帐户php页面上按照这些步骤操作, 1.检查是否设置了GET [&#39; wijzigen_id&#39;](您可以使用print_r进行打印以确认) 2.检查选择查询是否有效 3.检查$ data数组是否从db获取数据 4.尝试使用echo变量而不是