PHP:get_post有问题 [英] PHP: Having a problem with get_post
本文介绍了PHP:get_post有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在使用get_post方法时遇到问题.这是我的代码:
I am having a problem with the get_post method. Here is my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Upload2</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1> Welcome to my search Engine </h1>
<?php
# SETUP
$thisFile = 'v4.php';
# INPUT FIELDS
echo <<< END
<form action="$thisFile" method="post">
<pre>
Search <input type="text" name="searchTerm"/>
<input type="submit" value="Add Record"/>
</pre>
</form>
END;
# EXTRACT INPUTTED FIELDSA
if(isset($_POST['searchTerm'])) {
# INITIALIZE INPUTTED VARIABLES
$mySearchTerm = get_post('searchTerm'); # <- PROBLEM LINE!
echo "You searched for: $mySearchTerm";
}
?>
</body>
</html>
该代码在输入搜索词之前效果很好. html看起来像预期的那样,并且此页面显示在浏览器中:
The code works well before a search term is entered. The html looks as expected and this page is displayed in a browser:
输入搜索词后,进入查看"->页面源"后,页面看起来是相同的,但是我发现了一些有趣的东西.页面的结尾看起来像这样:
After I enter a search term the pages looks the same BUT after going View -> Page Source I noticed something interesting. The end of the page looks like this:
Search <input type="text" name="searchTerm"/>
<input type="submit" value="Add Record"/>
</pre>
</form>
注意:没有结尾</body></html>
推荐答案
事实证明,get_post不是PHP方法.我的课本在下一页将其定义为:
Turns out that get_post is not a PHP method. My textbook defined it on the next page as:
function get_post($var){
return mysql_real_escape_string($_POST[$var]);
}
这篇关于PHP:get_post有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文