<?php
include("../conn.php");
if (isset($_REQUEST['user_id'])){
	$user_id_input = mysqli_escape_string($conn, $_REQUEST['user_id']);
	$password_input = mysqli_escape_string($conn, $_REQUEST['password']);	

	$sql = "SELECT * FROM artist WHERE email = '$user_id_input' AND password = '$password_input'";
	$result = mysqli_query($conn, $sql) or die(mysqli_error($conn));
		
		
		if (mysqli_num_rows($result) == 1) {
			$info = mysqli_fetch_array($result);
				$id_output = $info['id'];
				$name = $info['name'];
				$picture = $info['picture'];
				$email = $info['email'];
				$password = $info['password'];
				$picture = $info['picture'];
				$type = $info['type'];
				
				session_start();
				$_SESSION['id_session']=$id_output;
				$_SESSION['name']=$name;
				$_SESSION['email']=$email;
				$_SESSION['type']=$type;
				
				if($_SESSION['type']=='admin'){
					header("Location:welcome.php");
				}elseif($_SESSION['type']=='artist'){
					header("Location:artists.php");
				}
				
			} else {
				print "				
				Sorry: either the Email or Password, you provide is incorrect. 
				<p>
				<a href=\"index.php\">Click here to try again</a>
				";			
			}	
}
?>