Jump to content

Recommended Posts

Hello people could you please explain me or make me look out what is wrong with this code?

 

Basically I have a table with some domains, after a query I split them by "," then I want to check if the referer is one of those domains in the DB, if true nothing happens, if not they got redirected to a new page, I can't figure out what is wrong, can someone please help me? sad.gif

 

Thanks in advance!

 

$streama= preg_replace("/[^a-zA-Z0-9\s]/", "", $_GET['ch']);
mysql_select_db($database_ovcast, $ovcast);
$query_Recordset1 = "SELECT nome, visitas, ban, password, dominio FROM CANAIS WHERE nome = '".$streama."'";
$Recordset1 = mysql_query($query_Recordset1, $ovcast) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

if ($row_Recordset1['dominio'] != "n/a"){

  $parts = split (",",$row_Recordset1['dominio']);


  $urlInfo = parse_url($_SERVER['HTTP_REFERER']);

   $domain = $urlInfo['host'];  

  $conta = count($parts);

  for ($i = 0; $i < $conta; $i++) {

  //echo $parts[$i]."\n";

  if ($parts[$i] <> $domain)
  {
  header("Location: http://#");

  //exit;
  }
  }
}

Link to comment
https://forums.phpfreaks.com/topic/268864-loop-issue/
Share on other sites

An example loop that im using on a cms im developing at the moment would be:

 


<?php

echo "<ul>";

$mainNav = select("*", "pages");
$Nav = $mainNav;
while($fetch = mysql_fetch_assoc($Nav)){

$path = $GLOBALS["siteUrl"]."/template/".$fetch["pageLink"];

if($fetch["active"] == 1 && $fetch["pageType"] == 1){
echo "<li><a href='".$path."'>".$fetch["name"]."</a></li>";
}
if($fetch["active"] == 1 && $fetch["pageType"] == 2){
echo "<li><a href='".$GLOBALS["siteUrl"]."/template/page.php?name=".$fetch["name"]."'>".$fetch["name"]."</a></li>";
}
if($fetch["active"] == 1 && $fetch["pageType"] == 4){
echo "<li><a href='".$path."'>".$fetch["name"]."</a></li>";
}

}

echo "</ul>";

?>

Link to comment
https://forums.phpfreaks.com/topic/268864-loop-issue/#findComment-1381458
Share on other sites

Not quite, I'm afraid. What he's saying is the normalize the database properly, or in other words: Store the domains in a table of their own, and use a foreign key relation.

 

These videos explain the concept rather nicely, and I recommend viewing them and researching the 3rd normal form until you understand the concept:

Link to comment
https://forums.phpfreaks.com/topic/268864-loop-issue/#findComment-1381465
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.