thecameraman 0 Newbie Poster

hello, I am trying to learn to create a login and log out profile. I am fairly new to php and web coding in general. I know the basics.

I found a tutorial that logs you into a profile and then logs you out. I want to be able to log in with email and password and then have the profile display only your information. right now I have it linking to a profile.php?id= but it only goes to that. If I can get it to profile.php?id=1 then it will work.

Below is the code I have now. If you can help that would be great. Thanks!

Profile page:

<?php
	require_once('php/SQLconnect.php'); 
	require ("php/common.php"); 

	require_once 'php/Membership.php';
	$membership = new Membership();

	$membership->confirm_Member();

	$id=0;
	if (isset($_GET['id'])) {
  		$id = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
	}
	$email='';
	if (isset($_GET['email'])) {
  		$email = (get_magic_quotes_gpc()) ? $_GET['email'] : addslashes($_GET['email']);
	}
?>

A verification page that links me to the profile.

class Membership {
	
	function validate_user($email, $password) {
		$mysql = New Mysql();
		$ensure_credentials = $mysql->verify_Username_and_Pass($email, $password);
		
		if($ensure_credentials) {
			$_SESSION['status'] = 'authorized';
			header("location: profile.php?id=".$id."");
		} else return "Please enter a correct username and password";
		
	} 
	
	function log_User_Out() {
		if(isset($_SESSION['status'])) {
			unset($_SESSION['status']);
			
			if(isset($_COOKIE[session_name()])) 
				setcookie(session_name(), '', time() - 1000);
				session_destroy();
		}
	}
	
	function confirm_Member() {
		session_start();
		if($_SESSION['status'] !='authorized') header("location: signin.php");
	}
	
}

and my connection page with a query to grab the email and pw

class Mysql {
	private $conn;
	
	function __construct() {
		$this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or 
					  die('There was a problem connecting to the database.');
	}
	
	function verify_Username_and_Pass($email, $password) {
				
		$query = "SELECT * FROM pickup WHERE email = ? AND password = ? LIMIT 1";
				
		if($stmt = $this->conn->prepare($query)) {
			$stmt->bind_param('ss', $email, $password);
			$stmt->execute();
			
			if($stmt->fetch()) {
				$stmt->close();
				return true;
			}
		}
		
	}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.