我想从我的数据库(mysql)中获取数据并将其显示在网站上,脚本应该被保存。
这是我已经拥有的文件结构:
/includes
db_connect.php
functions.php
getdata.php
logout.php
process_login.php
psl-config.php
register.inc.php
/js
forms.js
sha512.js
login.php
protected_page.php
register.php
register_success.php
seach.php
现在按照重要文件:psl-config.php
<?php
/**
* Das sind die Login-Angaben für die Datenbank
*/
define("HOST", "localhost"); // Der Host mit dem du dich verbinden willst.
define("USER", "sec_user"); // Der Datenbank-Benutzername.
define("PASSWORD", "eKcGZr59zAa2BEWU"); // Das Datenbank-Passwort.
define("DATABASE", "secure_login"); // Der Datenbankname.
define("CAN_REGISTER", "any");
define("DEFAULT_ROLE", "member");
define("SECURE", FALSE); // NUR FÜR DIE ENTWICKLUNG!!!!
?>
db_connect.php
<?php
include_once 'psl-config.php'; // Da functions.php nicht included ist
$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
?>
这是我的search.php
<?php
include_once 'includes/db_connect.php';
include_once 'includes/functions.php';
sec_session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Secure Login: Protected Page</title>
<link rel="stylesheet" href="styles/main.css" />
</head>
<body>
<?php if (login_check($mysqli) == true) : ?>
<p>Welcome <?php echo htmlentities($_SESSION['username']); ?>!</p>
<h3>Search Contacts Details</h3>
<p>You may search either by first or last name</p>
<form method="post" action="search.php?go" id="searchform">
<input type="text" name="name">
<input type="submit" name="submit" value="Search">
</form>
<?php else : ?>
<p>
<span class="error">You are not authorized to access this page.</span> Please <a href="login.php">login</a>.
</p>
<?php endif; ?>
</body>
</html>
我应该把我的文本框条目放在哪里才能安全地搜索我的网站?我的代码可以安全使用吗?
这是我的 sql 命令: SELECT * FROM produckte WHERE beschreibung = $search LIMIT 100;
我想在搜索网站上打印结果。