<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> new document </title> <style type = "text/css"> #outer{position:absolute; left:500px; top:300px; } </style> </head> <body > <div id = "outer"><form action = "127.0.0.1/formSearch.php" method = "post"><label for = "searchItem">Search Books:</label><input type = "text" name = "searchItem" id = "searchItem" size = "50" maxlength = "500" /><input type = "submit" value = "Search" /></form></div> </body></html><html><body><head><title>search result</title></head><script language = "php">$item = trim($_POST['searchItem']) ;if (!isset($item)){ echo "<p>what you want to search..</p>"; //$item = "javascript";}if (!get_magic_quotes_gpc()){ $item = addslashes($item);}$db = new mysqli("localhost", "root", "cai123",'phpdb');if (mysqli_connect_errno()){ echo "<p>can not to connect to database</p>";}$query = "SELECT * FROM books WHERE bookname LIKE"."'%".$item."%'";$result = $db->query($query);if (!$result){ echo "<p>no record was found...</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/xiazai/code/11072">
<img src="https://img.php.cn/upload/webcode/000/000/018/176484960870398.jpg" alt="威客">
</a>
<div class="aritcle_card_info">
<a href="/xiazai/code/11072">威客</a>
<p>PHP威客系统威客贰系统是国内领先的威客网站内容管理系统,基于PHP+Mysql架构开发。整合UCHOME系统,系统内容模块由:威客悬赏,招标任务,人才库,人才,招聘,新闻资讯,在线支付,发贴推广,案例示范等多种功能组成。 威客贰系统独创的单人悬赏、 多人悬赏 、计件悬赏 、 定金招标、 本地招标为核心任务模式。超强的发贴推广可以分配到不同的任务模式不同的会员等级有不同的提成费用,根据网站自身需要</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="威客">
<span>0</span>
</div>
</div>
<a href="/xiazai/code/11072" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="威客">
</a>
</div>
";}$items = $result->fetch_object();echo "<ul><li>ISBN: ".stripslashes($items->isbn)."</li>";echo "<li>bookname: ".stripslashes($items->bookname)."</li>";echo "<li>authors: ".stripslashes($items->authors)."</li>";echo "<li>prices: ".doubleval($items->prices)."</li></ul>";//$item->free();$db->close();</script></body></html>
路径跳转有问题
浏览器输入:127.0.0.1/formSearch.php
使用的是 http 协议,http://127.0.0.1/formSearch.php
只不过浏览器友好的免去了你输入 http:// 的麻烦
而 file:///E:/CodeEdit/php/127.0.0.1/formSearch.php
是文件系统协议
显然你的 html 代码不是通过 web 服务器访问的
所以应这样写
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号