<commit_before><html>
	<head>
		<link rel="stylesheet" type="text/css" href="css/normalize.css">
		<link rel="stylesheet" type="text/css" href="css/foundation.css">
		<title>SQL Injection and Prevention</title>
	</head>
<body>
<div class="row">
<div class="large-12 columns">
<h1>SQL Injection</h1>
<hr>
<?php
require_once('connect.php');


if($_POST['submit']=='Login'){
	//this line can cause sql injection
	$username = $_POST['username'];

	// this is to prevent sql injection
	//$username = mysql_real_escape_string($_POST['username']);
	$password = hash('<PASSWORD>',$_POST['password']);

	$query = "SELECT * FROM users WHERE password='$password' AND username='$username'";


	$sql = mysql_query($query);
	$rows = mysql_num_rows($sql);
	$temp=0;
	if($rows>=1){
		session_start();
		while($details = mysql_fetch_array($sql)){
			?>
			<h5><?php echo "<strong>UserID</strong>: ".$details[1]."<br>";?></h5>
			<h5><?php echo "<strong>Name</strong>: ".$details[1]."<br>";?></h5>
			<h5><?php echo "<strong>Username</strong>: ".$details[2]."<br>";?></h5>
			<hr>
			<?php
			$temp = $temp+1;
		}
		if($temp>1){
			?><h3 style="color:red"><strong><?php echo "SQL Injection Occured";?></strong></h3><?php
		}
		else if($temp==1){
			?><h3 style="color:green"><strong><?php echo "No SQL Injection Occured";?></strong></h3><?php
		}
	}
	else{
		echo "Please use valid credentials";
	}
}
if($_POST['submit']=='Register'){
	$name = $_POST['name'];
	$username = $_POST['username'];
	$password = <PASSWORD>('<PASSWORD>',$_POST['password']);
	$query = "INSERT INTO users(name,password,username) VALUES('$name','$password','$username')";
	$sql = mysql_query($query);
	$msg = "Registration Successful!";
	header("Location: index.php?msg=$msg");
}

?>
<a href="logout.php" class="button info">Logout and Try Again</a>
</div>
</body><commit_msg>userid correction<commit_after><html>
	<head>
		<link rel="stylesheet" type="text/css" href="css/normalize.css">
		<link rel="stylesheet" type="text/css" href="css/foundation.css">
		<title>SQL Injection and Prevention</title>
	</head>
<body>
<div class="row">
<div class="large-12 columns">
<h1>SQL Injection</h1>
<hr>
<?php
require_once('connect.php');


if($_POST['submit']=='Login'){
	//this line can cause sql injection
	$username = $_POST['username'];

	// this is to prevent sql injection
	//$username = mysql_real_escape_string($_POST['username']);
	$password = <PASSWORD>('<PASSWORD>',$_POST['password']);

	$query = "SELECT * FROM users WHERE password='$password' AND username='$username'";


	$sql = mysql_query($query);
	$rows = mysql_num_rows($sql);
	$temp=0;
	if($rows>=1){
		session_start();
		while($details = mysql_fetch_array($sql)){
			?>
			<h5><?php echo "<strong>UserID</strong>: ".$details[0]."<br>";?></h5>
			<h5><?php echo "<strong>Name</strong>: ".$details[1]."<br>";?></h5>
			<h5><?php echo "<strong>Username</strong>: ".$details[2]."<br>";?></h5>
			<hr>
			<?php
			$temp = $temp+1;
		}
		if($temp>1){
			?><h3 style="color:red"><strong><?php echo "SQL Injection Occured";?></strong></h3><?php
		}
		else if($temp==1){
			?><h3 style="color:green"><strong><?php echo "No SQL Injection Occured";?></strong></h3><?php
		}
	}
	else{
		echo "Please use valid credentials";
	}
}
if($_POST['submit']=='Register'){
	$name = $_POST['name'];
	$username = $_POST['username'];
	$password = <PASSWORD>('<PASSWORD>',$_POST['password']);
	$query = "INSERT INTO users(name,password,username) VALUES('$name','$password','$username')";
	$sql = mysql_query($query);
	$msg = "Registration Successful!";
	header("Location: index.php?msg=$msg");
}

?>
<a href="logout.php" class="button info">Logout and Try Again</a>
</div>
</body>
{'fraction_non_alphanumeric': 0.2406096897114861, 'fraction_numerical': 0.011976047904191617, 'mean_word_length': 5.830855018587361, 'pattern_counts': {'":': 0, '<': 110, '<?xml version=': 0, '>': 114, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2792310', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1326, 'n_words': 256}