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
Php - mysql select?
hi, i have this code:Code: <?phpsession_start();// dBase fileinclude "config.php";if ($_GET["op"] == "login") { if (!$_POST["username"] ||
Save file by click
Hello. I'm not understand how to save file from page. I'd like make link to file with save ability.<?phpchdir('upload/');foreach (glob("*.*") as $filename) { $uploadfile =
mod_rewrite.c on windows ??
why it's not working on windows while it's working on other hosts??? this is the code i got from a tutorial :Code: <IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /rewriterule
onclick problem
I have <input type="text" name="message"><a href=page2.php>click here</a> Can i parse the value whatever written in the textbox on url
INSERT data problem!
After having an string with apostrophes ', double quotes " or any other special characters, successfully escaped through one of themany php functions availables to escape, what other
Need help with simple code, back and forward buttons.
Basically, I have a set of pages in a folder, which have the title somephrasehere_09.php, somephrasehere_10.php, somephrasehere_11.php, etc. On each of these pages, I want to include a common code
Rand() help needed
Hi all,Can someone explain and give me a quick example of how I would go about this?I have 100 values in a database with colum headings of t_val and t_name. If I wanted to update all 100 of these
Record count of entire database
Does anyone know if there is a way to obtain the number of records in each table of the database using a single select statement or must a select count be done for each individual table?
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
passing an array of objects after submit
How do I do this? This is what I have tried and it is not working.<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"><input