note 109474 modified in function.header by danbrown

From: Date: Fri, 20 Jul 2012 14:46:06 +0000
Subject: note 109474 modified in function.header by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189323@lists.php.net to get a copy of this message
You can use header(); function to show programs Errors&#13;&#10;for example&#13;&#10;&#13;&#10;// Errors.php&#13;&#10;&#60;?php&#13;&#10;if(isset($_GET[&#39;iderror&#39;]))&#13;&#10;{&#13;&#10;echo &#39;&#60;div align=&#34;center&#34;&#62;&#39;;&#13;&#10;switch($_GET[&#39;iderror&#39;])&#13;&#10;{&#13;&#10;case 1:&#13;&#10;echo &#34;we can not found your username or password&#34;;&#13;&#10;breaak;&#13;&#10;case 2:&#13;&#10;echo &#34;please login&#34;;&#13;&#10;break;&#13;&#10;}&#13;&#10;echo &#39;&#60;/div&#62;&#39;;&#13;&#10;}&#13;&#10;else&#13;&#10;{&#13;&#10;echo &#34;please send your Errors code&#34;;&#13;&#10;}&#13;&#10;?&#62;&#13;&#10;&#13;&#10;//panel.php&#13;&#10;&#60;?php&#13;&#10;// ...&#13;&#10;if($_SESSION[&#39;access&#39;] == &#34;&#34;)&#13;&#10;{&#13;&#10;header(&#34;Location: Errors.php?id=1&#34;);&#13;&#10;}&#13;&#10;if($_SESSION[&#39;username&#39;] == &#34;&#34;)&#13;&#10;{&#13;&#10;header(&#34;Location: Errors.php?id=2&#34;);&#13;&#10;}&#13;&#10;?&#62; --was-- You can use header(); function to show programs Errors for example // Errors.php <?php if(isset($_GET['iderror'])) { echo '<div align="center">'; switch($_GET['iderror']) { case 1: echo "we can not found your username or password"; breaak; case 2: echo "please login"; break; } echo '</div>'; } else { echo 'please send your Errors code"; } ?> //panel.php <?php ... if($_SESSION['access'] == "") { header("Location: Errors.php?id=1"); } if($_SESSION['username'] == "") { header("Location: Errors.php?id=2"); } ?> http://php.net/manual/en/function.header.php

« previous php.notes (#189323) next »