我一直在努力學習PHP一段時間的簡單的網站。我使用bootstrap製作了一個簡單的php表單。
我使用GET方法來從輸入到URL文本,它顯示了在此處顯示的URL的search.php: URL
文件結構: Screenshot of directories
對於一些原因,當我嘗試在search.php頁面上回顯值時,網頁是空白的。我可能犯了一個愚蠢的錯誤,所以任何幫助都會很棒!
的index.php代碼:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mc Report</title>
<meta name="description" content="Mc Report">
<meta name="author" content="Cre8tionz">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap-theme.css">
<script>
$(function(){
$(".dropdown-menu li a").click(function(){
$(".but:first-child").text($(this).text());
$(".but:first-child").val($(this).text());
});
});
</script>
</head>
<body>
<div class="container container-table">
<div class="row vertical-center-row">
<div class="text-center col-lg-8 col-lg-offset-2">
<div class="main-logo">
<img src="img/logo.png"></img>
</div>
<div class="row">
**<form action="search.php" method="get" novalidate="novalidate">
<div class="col-lg-10">
<div class="input-group">
<input name="q" type="search" class="form-control" aria-label="..." placeholder="Search for a username">
<div class="input-group-btn">
<button type="button" class="but btn btn-default dropdown-toggle pull-right" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Catageory<span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right">
<li><a href="#">Mc-Market Username</a></li>
<li><a href="#">Minecraft Username</a></li>
<li><a href="#">Minecraft UUID</a></li>
</ul>
</div>
</div>
</div>
<div class="col-lg-2">
<div class="btn-group" role="group" aria-label="...">
<button type="submit" class="btn btn-default">Search</button>
</div>
</div>
</form>**
</div>
</div>
<footer>
<div class="footer">
<div class="container narrow row-fluid text-center navbar-fixed-bottom">
<div class="col-lg-4">
Mc Report
</div>
<div class="col-lg-4">
About
</div>
<div class="col-lg-4">
Copyright © 2016
</div>
</div>
</div>
</footer>
</div>
</div>
</body>
</html>
的search.php代碼:
<html>
<body>
<?php
if($_GET["q"]) {
print_r($_GET);
$searchquery = $_GET["q"];
echo $searchquery;
}
?>
</html>
</body>
您的代碼在* search.php *文件的環境中工作以除去除* php *代碼之外的html代碼。也刪除〜phpinfo()〜 – Karthi
我認爲你是從文件打開該頁面,而不是從服務器(lampp,xampp,wamp ...)打開。 Php頁面必須由服務器首先處理 – Aleksandar
@Aleksandar我在Xampp服務器上有它,但它仍然不能正常工作:https://i.gyazo.com/96ff60591c7dfbb3c6fc231e1360cad3.png – Cre8tionz