Jump to content

Is This Valid?


phpSensei

Recommended Posts

Before Anything, I think I should Explain how my Forum works.

 

Everytime a user adds a topic, the Id of the Forum which the topic is being added to, is inserted in a table row called id_forum, in the messages table. (Same table for Adding Topics).

 

Once it has the Forum's id, you can display these topics like this

 

<?php

//We Get the ID of the Topic passed from the URL//
$id=$_GET['id'];

//Here We Select Everything from Messages, then INNER JOIN with the Forums table//
$sql="SELECT * FROM messages INNER JOIN forums  ON id_message=id_forum  WHERE id_forum='$id'  ";


$result=mysql_query($sql);
$row=mysql_fetch_array($result);

?>

 

 

 

I am trying to Collect a user's ip when he views a thread in my forum.

 

Now to skip some of the code, I will do a IF statement for:

 

<?php

//Here we Collect the IP Adress of this user//
$ip=$_SERVER['REMOTE_ADDR']; 
//Here we check if in OUr SELECT STATEMENT, We can Find a unique ip//
If( $ip == $row['unique_ip']){

//If The ip already Exists, We do Not ADD 1 to the Unique Views//
die();
}
//Else If the ip is unique, We add it to our list of Ip's, so Later this ip will not count as unique//
elseif ($ip != $row['uniqure_ip']{


$id=$_GET['id_message'];

mysql_query ("INSERT INTO message_msg (uip) WHERE id_msg='$id' VALUES ('$ip')")

mysql_query("UPDATE messages SET uniqueviews = uniqueviews + 1 WHERE message_id='$id2'");
}

?>

 

The ip doesnt go to the proper message id.

Link to comment
https://forums.phpfreaks.com/topic/60092-is-this-valid/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.