RE: control structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Chris Stinemetz [mailto:chrisstinemetz@xxxxxxxxx]
> Sent: Thursday, August 04, 2011 11:34 PM
> To: PHP General
> Subject:  control structure
> 
> I have a php script with a simple condition. If it is not satisfied I
> want to exit the script otherwise I want to continue. I am having
> difficulties getting it to work. The script is just exiting..
> 
> Please excuse my indention. Gmail tends to distort it.
> 
> Thank you,
> 
> Chris
> 
> This is what i have so far:
> 
>     if (!session_id())
> 	{
> 	session_start();
> 	}
>     if($_SESSION['signed_in'] == false | $_SESSION['user_level'] != 1
> || $_SESSION['user_level'] != 2  )
> 	{
> 	//the user is not an admin
> 	echo 'Sorry, you do not have sufficient rights to access this
> page.<br/>
> 	      You must be a technician or an engineer to create a store
> visit.';
> 
> 	      exit;
> 	}
> 	else {
> 	    continue;
> 
> 
> 
> If I get it to continue I want to execute the rest of the script, but
> It will only exit. Current user has user_level of 1 so that is not an
> issue.
> 
> Rest of script:
> 
>     $market = isset($_GET['market']) ? $_GET['market'] :
> $_SESSION['market'];
>     $type = isset($_GET['type']) ? $_GET['type'] : $_SESSION['type'];
>     $store = isset($_GET['store']) ? $_GET['store'] :
> $_SESSION['store'];
> 
>     $type = str_replace('-', ' ', $type);
> 
>     if($_SESSION['type'] != $type)
>         {
>         $_SESSION['type'] = $type;
>         $store = '';
> 		}
> 
>     if($_SESSION['market'] != $market)
>         {
>         $type = '';
>         $store = '';
>         }
> 
>         $_SESSION['market'] = $market;
>         $_SESSION['type'] = $type;
>         $_SESSION['store'] = $store;
> 
>         $market_name = array();
>         $market_prefix = array();
>         $type_name = array();
>         $market_prefix = array();
>         $store_name = array();
> 
> 
>     $query = "SELECT * FROM marketcode " ;
>     $result = mysql_query($query) or die(report($query,__LINE__
> ,__FILE__)); //("Something went wrong");
> 
> 	while($row = mysql_fetch_array($result))
>         {
>         $market_name[] = $row['market_name'];
>         $market_prefix[] = $row['market_prefix'];
>         }
> 
>     $query = "SELECT store_type FROM store_type WHERE market_prefix =
> '$market' "     ;
>     $result = mysql_query($query) or die(report($query,__LINE__
> ,__FILE__));
> 
> 	while($row = mysql_fetch_array($result))
>         {
>         $type_name[] = $row['store_type'];
>         }
> 
>         $type_name = array_unique($type_name);
>         sort($type_name);
> 
>         if($type == '')
>             {
>             $type = $type_name[0];
>             $_SESSION['type'] = $type;
>             }
> 
>     $query = "SELECT store_name FROM store_list WHERE store_type =
> '$type' AND market_prefix = '$market' "      ;
>     $result = mysql_query($query) or die(report($query,__LINE__
> ,__FILE__));
> 
>     while($row = mysql_fetch_array($result))
>         {
>         $store_name[] = $row['store_name'];
>         }
>              //   include ('includes/closedb.php');
>    // close dB
>         sort($store_name);
>      }
> ?>
> 
>         <div id="myspan">
>         <form action="index.php" method="post">
>             <table>
>                 <tr>
>                     <th class="market">Market</th>
>                     <th class="type">Store Type</th>
>                     <th class="store">Store Name</th>
>                 </tr>
>                 <tr>
>                     <td>
>                     <select name="market"
> onchange="javascript:get(this.parentNode);">
> 					<option value="">Choose...</option>
>                     <?php
>                         foreach($market_prefix as $key => $value)
>                             {
>                             $selected = '';
>                             if($value == $market)
>                             {
>                             $selected = 'selected';
>                             }
>                             //echo("<option value=$value $selected
> >$value : $market_name[$key]");
> 							echo '<option
value="',
> htmlspecialchars($value), '" ',
> $selected, '>', htmlspecialchars($value.' : '.$market_name[$key]),
> '</option>';
>                             }
>                             ?>
>                     </select>
>                     </td>
>                     <td>
>                     <select name="type"
> onchange="javascript:get(this.parentNode);">
> 					<option value="">Choose...</option>
>                     <?php
>                         foreach($type_name as $value)
>                             {
>                             $selected = '';
>                             if($value == $type)
>                             {
>                             $selected = 'selected';
>                             }
>                             $v = str_replace(' ', '-', $value);
>                             //echo("<option value=$v $selected
> >$value");
> 							echo '<option
value="',
> htmlspecialchars($v), '" ', $selected,
> '>', htmlspecialchars($value), '</option>';
>                             }
>                     ?>
>                     </select>
>                     </td>
>                     <td>
>                     <select name="store">
> 					<option value="">Choose...</option>
>                     <?php
>                         foreach($store_name as $value)
>                             {
>                             echo("<option value=$value>$value");
> 	            }
>                     ?>
>                     </select>
>                     </td>
>                     </tr>
>                     <tr>
>                     <td>
>                         <p>
>                             <input type="hidden" name="step" value="2">
>                             <input type="submit" name="submit"
> value="Submit">
>                         </p>
>                     </td>
>                     </tr>
>             </table>
>         </form>
>     </div>
>     </body>
> </html>
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



	// This part makes no sense they are not logged in and they have a
level of 1 or 2 ?
	// And you was missing a Pipe after false. It will cause the If
statement to fail.

	if($_SESSION['signed_in'] == false || $_SESSION['user_level'] != 1
|| $_SESSION['user_level'] != 2  ) {







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux