<commit_before>
<?php
/* This piece of code allows the user to log into the website using php and MySQL. */



/*I have assigned the value two text boxes "username" and "password" to $username and 
$password.*/

/*Rename the appropiate log in boxes in Embo's Login.HTML to allow the assigning of variable*/
$username = $_POST['username'];
$password = $_POST['password'];


if ($username != "" && $password != "")
{

/*This connects to the MySQL database "users".*/

/*Check appropiate data to insure that the php file can connect to the SQL server.*/
$connect = mysql_connect("localhost", "webd_wt2user", "RD3%JgdAcI5!" ) or die("Couldn't connect");
mysql_select_db("webd_wt2") or die ("Couldn't find Database");

/*This selects the row from the table "users" where the user name field is equal to 
"$username".*/
$query = mysql_query("SELECT * FROM Tutors WHERE Tutor_ID='$username' ");
/*This counts the number of rows within the database.*/
$numrows = mysql_num_rows($query);

	/*If $username is equal to the user field within the table the following piece of code will 
	be out put.*/
	if ($numrows != 0)
		{
		
		/*This will search the tables data to find the correct username and password, once 
		they have been found they will be assinged the values $dbusername and 
		$dbpassword.*/
		while ($row = mysql_fetch_assoc($query))
			{
				$dbusername = $row['Tutor_ID'];
				$dbpassword = $row['Password'];
			}

		/*If the username and password are equal too "Admin" and "<PASSWORD>" then you 
		will be redirected to the phpmyadmin page.*/
		
		/*This is the Admin account feature, it will allow the Admin to log into the server with special privlidges.*/
		
		if ( $username == admin && $password == <PASSWORD>)
			{
			echo "you're in! <a href='http://www.webdesign.lincoln.ac.uk/wt2/phpMyAdmin.php'>Click</a> here to enter the members page.";
			exit;
			}

		else
			
			{
			
				/*If the username and password are not equal to that but the username and 
				password can be found within the table the following code will be performed.*/
                $MD5password = md5($password);			
				
				/*Insert the appropiate data to ensure the message is customiseable.*/
				if ($username == $dbusername && $MD5password==$dbpassword)
					{
						echo "you're in! <a href='StaffProfile.html'>Click</a> here to enter the members page.";
						$_SESSION['username']=$dbusername;
					}
				
				else 
				
				/*If the username and password aren't equal to that in the data base it will output 
				"incorrect password" the reason for this is that the username would of already 
				been correct as this if statement needs a valid username to search the table.*/	
					echo "incorrect password!";
			
				}	
			}

	/*If the username cannot be found within the table the message "thats user doesnt exist"
	and then kill this process.*/
	else
		die("That user doesn't exist.");<commit_msg>Added sessions to the log in system<commit_after>
<?php
/* This piece of code allows the user to log into the website using php and MySQL. */
//Start session
session_start();


/*I have assigned the value two text boxes "username" and "password" to $username and 
$password.*/

/*Rename the appropiate log in boxes in Embo's Login.HTML to allow the assigning of variable*/
$username = $_POST['username'];
$password = $_POST['password'];


if ($username != "" && $password != "")
{

/*This connects to the MySQL database "users".*/

/*Check appropiate data to insure that the php file can connect to the SQL server.*/
$connect = mysql_connect("localhost", "webd_wt2user", "RD3%JgdAcI5!" ) or die("Couldn't connect");
mysql_select_db("webd_wt2") or die ("Couldn't find Database");

/*This selects the row from the table "users" where the user name field is equal to 
"$username".*/
$query = mysql_query("SELECT * FROM Tutors WHERE Tutor_ID='$username' ");
/*This counts the number of rows within the database.*/
$numrows = mysql_num_rows($query);

	/*If $username is equal to the user field within the table the following piece of code will 
	be out put.*/
	if ($numrows != 0)
		{
		
		/*This will search the tables data to find the correct username and password, once 
		they have been found they will be assinged the values $dbusername and 
		$dbpassword.*/
		while ($row = mysql_fetch_assoc($query))
			{
				$dbusername = $row['Tutor_ID'];
				$dbpassword = $row['Password'];
			}

		/*If the username and password are equal too "Admin" and "<PASSWORD>" then you 
		will be redirected to the phpmyadmin page.*/
		
		/*This is the Admin account feature, it will allow the Admin to log into the server with special privlidges.*/
		
		if ( $username == admin && $password == <PASSWORD>)
			{
			echo "you're in! <a href='http://www.webdesign.lincoln.ac.uk/wt2/phpMyAdmin.php'>Click</a> here to enter the members page.";
			exit;
			}

		else
			
			{
			
				/*If the username and password are not equal to that but the username and 
				password can be found within the table the following code will be performed.*/
                $MD5password = md5($password);			
				
				/*Insert the appropiate data to ensure the message is customiseable.*/
				if ($username == $dbusername && $MD5password==$dbpassword)
					{
						
						$_SESSION['username']=$dbusername;
                        session_write_close();
                        echo "you're in! <a href='StaffProfile.html'>Click</a> here to enter the members page.";
					}
				
				else 
				
				/*If the username and password aren't equal to that in the data base it will output 
				"incorrect password" the reason for this is that the username would of already 
				been correct as this if statement needs a valid username to search the table.*/	
					echo "incorrect password!";
			
				}	
			}

	/*If the username cannot be found within the table the message "thats user doesnt exist"
	and then kill this process.*/
	else
		die("That user doesn't exist.");
{'fraction_non_alphanumeric': 0.10821778829895164, 'fraction_numerical': 0.003043625295908015, 'mean_word_length': 3.2584593232541397, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2571573', 'n_tokens_mistral': 1957, 'n_tokens_neox': 1662, 'n_words': 741}