Jump to content

[SOLVED] query statement not working...


ccrevcypsys

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");
			}
		}
	}
}
?>

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.