html - Can i do these in PHP if conditions? -


this code had in sites table , first check if typed url there after check status of url, if status = block echo telling site blocked, apparently ever status in table of url, being blocked, shouldn't

<?php  $servername = "localhost";  $username = "root";  $password = "";  $dbname = "repute system";  // create connection  $conn = new mysqli($servername, $username, $password, $dbname);  // check connection_aborted(oid)  if ($conn->connect_error) {      die("connection failed: " . $conn->connect_error);  }     $url = $_post['url'];  $sql = "select * sites " ;    $result = $conn->query($sql);    if ($result->num_rows > 0) {      while($row = $result->fetch_assoc()) {      	$stat = $row['status'];      	if($stat = 'block' && $url == $row['url'])      	{         echo "this site blocked" ;         die();        }      }        header("location: $url");  }  ?>

i use &&, || or , , or in if statements here? , worried header statement have heard quite unstable use, why ? substitute redirect urls?

i'm putting comment answer: (22:13:54z)

if($stat = 'block' you're assigning $stat block , true.

you need compare if($stat == 'block' / using 2x equal signs check if $stat equals block.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -