I use the below to verify user login. I first check the cookie for the id, ip and a unique id. If it's set then I move on to verifying that they all belong together. I usually copy and paste everything on a page that needs verification and I just edit the "we are good...." part.
Login verification
<?php
//Check to see if cookie is set
if (isset($_COOKIE['id']) && isset($_COOKIE['ip']) && isset($_COOKIE['uniqueid'])){
$cookieid = $_COOKIE['id'];
$cookieip = $_COOKIE['ip'];
$cookieuniqueid = $_COOKIE['uniqueid'];
require('header.php');
//Select id and loginip according to cookie uniqueid
$query = "SELECT * FROM user WHERE uniqueid = '$cookieuniqueid' LIMIT 1";
if ($result = mysql_query ($query)) {
while ($row = mysql_fetch_array ($result)) {
$id = $row['id'];
$uniqueid = $row['uniqueid'];
$ip = $row['ip'];
}
}
//Compare cookie ip and id with query loginip and id --- if cookies match database then we allow
if ($_COOKIE['id'] == $id && $_COOKIE['ip'] == $ip && $_COOKIE['uniqueid'] == $uniqueid) {
?>
we are good....
<?php
require('footer.php');
//End cookie compare
}
//Redirect to index if cookie compare fails
else {
header('Location: index.php');
}
//End cookie set
}
//Redirect to index if cookie is not set
else {
header('Location: index.php');
}
?>
I was wondering if there was a way for me to just do something like:
<?php
require('verify.php');
//If not logged in user wont see the below..
?>
Login user sees this
Problems with array
This code is the last lines in an upload script that uploads 4 images at the same time and writes the url to these and som other information to the database. database structure: id img1 img2 img3
SQL Query/echo not working
Hey all,I'm trying to run (what I thought) was a simple operation and it isn't working. I haven't coded anything in about 2 years, and I'm self taught at that so I know I've got quite a few gaps in
mysql_real_escape_string
Let me preface this that I am very much a PHP noob, but I have some SQL training (not necessarily MySQL, we used the Microsoft variety in school). I have a weird problem, I'm trying to create a
filesize() returns 0
I have a socket program that runs in an infinite loop, listening for connections, in this socket I have a method, that is supposed to open a file and write to the file, but I am having issues. Each
IP question
ive got 2 ip addresses both global from same user how would i detect if they are local to each other
Unique Visitor Tracking
Hello. Currently, I run a voting site where voters are tracked by their IP address and can only vote once every 12 hours.The system works well, except it can be exploited very easily. Visitor's only
Remove values in array2 from array1
I have two arrays.Array 1 is where the array key holds various different numbers. For example:Code: [Select]$array[32] = 1;$array[122] = 1;$array[238] = 1;$array[324] = 1;The other array holds values
mysql select with $_get ?
Hi, i have this code:Code: // If char id is 0 and character dont exist do:if ($_GET["id"] == "0"){die "A character ID can never be 0. This character does not exists or have
distinct rows
Hi
Log $_POST
How would i log submits on a form, by everyone? I want to then echo the number of submissions.I've tried this:Code: [Select]<?phpif (isset($_POST['submit'])) {$myFile =