How to use the specific content we will explain to you todayThe following is a script called calling.php:
<ol class="dp-xml"> <li class="alt"><span><span><!DOCTYPE HTML PUBLIC </SPAN></SPAN><LI class=""><SPAN>"-//W3C//DTD HTML 4.0 Transitional//EN" </SPAN><LI class=alt><SPAN>"http://www.w3.org/TR/html4/loose.dtd" </SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span><span> </span></span></li> <li class=""> <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>html</SPAN><SPAN class=tag>></span></font></strong><span> </span> </li> <li class="alt"> <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>head</SPAN><SPAN class=tag>></span></font></strong><span> </span> </li> <li class=""> <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>title</SPAN><SPAN class=tag>></span></font></strong><span>Calling page example</span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>title</SPAN><SPAN class=tag>></span></font></strong><span> </span> </li> <li class="alt"> <span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>head</SPAN><SPAN class=tag>></span></font></strong><span> </span> </li> <li class=""> <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>body</SPAN><SPAN class=tag>></span></font></strong><span> </span> </li> <li class="alt"> <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>a</SPAN></FONT></STRONG><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>href</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"action.php"</FONT></SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong><span>Click here!</span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>a</SPAN><SPAN class=tag>></span></font></strong><span> </span> </li> <li class=""> <span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>body</SPAN><SPAN class=tag>></span></font></strong><span> </span> </li> <li class="alt"> <span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>html</SPAN><SPAN class=tag>></span></font></strong><span> </span> </li> </ol>
When the user clicks the above link, the PHP function header() calls action.php. The following is the source code of action.php:
<ol class="dp-xml"><li class="alt"> <span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN> </SPAN></SPAN><LI class=""><SPAN>// 数据库功能 </SPAN><LI class=alt><SPAN> </SPAN><LI class=""><SPAN>// 重定向 </SPAN><LI class=alt><SPAN>header("Location: $HTTP_REFERER"); </SPAN><LI class=""><SPAN>exit; </SPAN><LI class=alt><SPAN></SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong></span><span> </span> </li></ol>
There are two common mistakes that need to be reminded:
After calling the PHP function header(), you must include an exit statement to stop the script, otherwise subsequent scripts may be sent before the header is sent. output.
A common error in the header() function is:
Warning: Cannot add header information - headers already sent...
PHP function header() can only be used in HTML Output is called before, so you need to check for possible empty lines, spaces, etc. in front of php.