我有一个HTML表单中的文本框,用户将在其中输入一些信息并按提交。这些数据将提交到同一页面,所以我想在文本框中显示上次提交的值。
我试着这样做:
<input name="srq" type="text" id="search_box" <?php if($_GET["srq"]) echo value=" .$_GET["srq"]. " ; ?> />
但这会把“你好”变成“你好”。做这件事的正确方法是什么?
我有一个HTML表单中的文本框,用户将在其中输入一些信息并按提交。这些数据将提交到同一页面,所以我想在文本框中显示上次提交的值。
我试着这样做:
<input name="srq" type="text" id="search_box" <?php if($_GET["srq"]) echo value=" .$_GET["srq"]. " ; ?> />
但这会把“你好”变成“你好”。做这件事的正确方法是什么?
一种解决方案可能是关闭php设置中的magic_quotes_gpc,或者另一种是在$_GET[“srq”]中使用条带斜线
<?php if($_GET["srq"]) echo value=" .stripslashes($_GET["srq"]). " ; ?>
我想你知道那有多没有保障吧?
echo value=" . htmlspecialchars($_GET[ srq ]) . "
并且不要自动添加斜线。如果需要在数据库中插入一些内容,请使用数据库转义函数对其进行转义(例如mysql的mysql_real_eescape_string()
),而不是依赖斜杠。
使用在输出值时使用stripesashes函数。
你有神奇的引号=打开
使用get_magic_quotes_gpc检查它们是否打开,然后使用条带斜杠以删除引号
I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....
I have a div <div id="masterdiv"> which has several child <div>s. Example: <div id="masterdiv"> <div id="childdiv1" /> <div id="childdiv2" /> <div id="...
I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...
<form><input type="file" name="first" onchange="jsFunction(2);"> <input type="file" name="second" onchange="jsFunction(3);"</form> Possible to pass just numbers to the js ...
So I ve got a menu with a hover/selected state and it loads fine in IE6/IE7. However when I scroll down the page and put the element outside of the viewport and then back in I get a broken image! I ...
I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!