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 multiple action on submit
I have a form which says:<form enctype='multipart/form-data' method='post' action='process.php' target='_blank'>I need to call process.php on submit or on clicking submit button. Now
urldecode question
How would I format this line of code properly?<?php echo urldecode($_GET['Title']); ?>
unexpected T_SL without a shift left token
Nothing too see here, I'm an idiot and resolved the problem.
MySql timezone
Code: $sql = "SELECT *, date_format(date, '%m/%d/%Y at %I:%i %p' )as date FROM comments WHERE tutorialid='1' ORDER BY commentid DESC LIMIT $offset, $rowsperpage";Can I change the timezone
using explode() to fill in checkboxes
HiI have a field stored in a table that contains regions in the UK separated by commas. There could be any number of pieces held in this field from 1-12, based upon the users specified operating
SQl num_rows problem
when i try to count rows from an SQL select i get an warningCode: [Select]$countviews = mysql_query("SELECT * FROM viewed WHERE sfw = '0' AND cookieid = $id");$num_rows_viewed =
button help
i originally had this but realised it is much easier to have a button.Code: <?php$search = $_GET['search'];$checkbox = $_GET['checkbox'];if($checkbox ==
array & querys help/advice.
Ok so here goes , I have a mysql database and basically here's what I need to do.// foreach store id// foreach product id {// query with where store id and product id// get price row for each
Delete all from a table
I can not get the following code to work. If I run the sql statement in the db it will delete all the data but it will not work from the page. My connection string is fine I just can not get it to
using file_get_contents??
okay how would i create a script using file_get_contents() in php have it grab search pages 1-20 and return the results based on whatever username was typed into the form.liek for example i would type