Home > php教程 > php手册 > 论坛内容的简单输出

论坛内容的简单输出

WBOY
Release: 2016-06-06 19:33:28
Original
774 people have browsed it

无详细内容 无 htmlbody meta charset="utf-8" form action='' method='post' 标题:input type='text' name='text'br 内容:textarea name='te' cols='20' rows='3'/textarea select name="check" option value='谢谢您'谢谢您/option option value='您好'您

<html>
	<body ><meta charset="utf-8">
    <form action='' method='post'>
		    标题:<input type='text' name='text'><br>
		    内容:<textarea name='te' cols='20' rows='3'></textarea>
		   <select name="check">
			   <option value='谢谢您'>谢谢您</option>
			   <option value='您好'>您好</option>
			   <option value='再见'>再见</option>
		   </select><br>
		  <p> </p>
		   <input type='submit' name='sub' value='确定'>
		   <input type='reset' name='res' value='重置'>
	</form>
	<?php
		function str($str){								//自定义函数。
			$str = preg_replace("/ /"," ",$str);			//替换空格。
			$str = preg_replace("/cha(13)/","<br>",$str);		//替换回车符。
			echo "内容:".$str;							//输出。
		}
		if(!empty($_POST["sub"])){								//通过post方式传参。
		//如果text为空或者文本域和下拉列表框同时为空。
			if($_POST["text"] == "" || (($_POST["te"] == "") && ($_POST["check"] == 1))){
				echo "<script>alert('内容不能为空');location.href='index.php'</script>";		//输出提示。
			}else{									
				   
					  if(!empty($_POST["check"]) || $_POST["select"] != '1'){				//当下拉列表值不等于1时
						  echo "<br>标题:".$_POST["text"]."<br>";	//输出内容和下拉列表内容。
						  str($_POST["te"].$_POST["check"]);
					  }else{						
						  echo "标题:".$_POST["text"]."<br>";	//否则只输出文本域内容。
						  str($_POST["te"]);
				      }
			}
		}
?>
</body>
</html>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template