Jump to content

Recommended Posts

and i dont know why. Here is the hole page of code. I dont know why it isnt going...

<?php
if($_POST['email']==TRUE){
//Check if already logged in
	$query = "SELECT * FROM `sessions` WHERE customer_id = 36";
	$result = mysql_query($query)or die(mysql_error()."error 1");
	$row = mysql_fetch_array($result, MYSQL_NUM)or die(mysql_error()."error 2");
	if($row==FALSE){
		$querys = "SELECT customer_id, firstName FROM customer WHERE email = '".$_POST['email']."' AND password='".$_POST['password']."'";
		$results = mysql_query($querys)or die(mysql_error()."error 3");
		$rows = mysql_fetch_array($results, MYSQL_ASSOC)or die(mysql_error()."error 4");
		$login = $_POST['email'];
		if($rows){
		$sessId = rand(50,1000);
			$insert = mysql_query("INSERT INTO sessions (sessId,customer_id,timeStart,timeLast) VALUES (".$sessId.",".$row[0].", ".date('his').",".date('his').")")or die(mysql_error());
			if($insert==TRUE){
			setcookie("sessId", $sessId, time()+3600);

			header("Location: index.php?p=V");
			}
		}
	}else{
	echo "Already Logged in... <br /> Click Here To Destroy This Session!";
	}
}

?>

Link to comment
https://forums.phpfreaks.com/topic/84173-solved-query-statement-not-working/
Share on other sites

ok well i fugured it out.. so it works now but what i need to do is set up a checking system for the login. But i cant get it.

so heres what i have and it doesnt work how i want it to ( i want it so that when someone tries to login and there is already a session i will have it update the information in the db with the new sess data and the new times instead of making 1.3 billion of them over the course of the next 2 weeks lol. so if you can help it would be awsome )

<?php

if($_POST['email']==TRUE){
//Check if already logged in
	$query = "SELECT * FROM `sessions`";
	$result = mysql_query($query)or die(mysql_error()."error 1");
	$row = mysql_fetch_array($result, MYSQL_ASSOC)or die(mysql_error()."error 3");
	if($row == TRUE && $row['customer_id']=="36"){
	echo "Already Logged In Click Here To Destroy All Sessions.";
	}else{
		$querys = "SELECT * FROM customer WHERE email = '".$_POST['email']."' AND password='".$_POST['password']."'";
		$results = mysql_query($querys)or die(mysql_error()."error 1");
		$rows = mysql_fetch_array($results, MYSQL_ASSOC)or die(mysql_error()."error 2");
		$login = $_POST['email'];
		if($rows){
		$sessId = rand(50,1000);
			$insert = mysql_query("INSERT INTO sessions (sessId,customer_id,timeStart,timeLast) VALUES (".$sessId.",".$rows['customer_id'].", ".date('his').",".date('his').")")or die(mysql_error());
			if($insert==TRUE){
			setcookie("sessId", $sessId, time()+3600);
			setcookie("customer_id", $rows['customer_id'], time()+3600);
			header("Location: index.php?p=V");
			}
		}
	}
}
?>

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.