Click here to Skip to main content
15,881,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my login is not working and i am getting this error. cyah seem to get rid of it here is what i have tried both the php and html

What I have tried:

PHP
<pre><?php
	include'db_server.php';
	
	
	
		
		$login=$_POST['login_user'];
	if(isset($login))
	{
			// capture the values from the form and store in php variable
		$screenname=$_POST['screenname'];
		$mypwd=$_POST['mypwd'];
		
	
		include'db_server.php';
		
		mysqli_select_db($conn, 'national_wonders');
		
		$sql= "SELECT * FROM login WHERE $screenname='$screenname' AND mypwd = MD5('$mypwd')";
		
		$result = mysql_query($conn, $sql) or die("ERROR:" .mysql_error($conn));
		
		$rowcount=mysql_num_rows($result);
		
		if($rowcount ==1)
		{
			
			echo"<script type=\"text/javascript\">
			alert('Screenname and password does not exist!');
			window.location=\"../xhtml/login.html\";
			</script>";
			
		}
		else
		{
			echo"<script type=\"text/javascript\">
			alert('Screenname and password does not exist!');
			window.location=\"../xhtml/login.html\";
			</script>";
		}
		mysqli_close($conn);
		
	
	}
?>	


here is the htmml code
HTML
<pre><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title> Login </title>
		<link rel="stylesheet" type="text/css" href="../css/stylesheet.css" />
	</head>
	<body>
		<div id="container" >
			<div id="header">
				<img src="../images/header.jpg" alt="header" />
			</div>
			<div id="navbar">
				<ul>
					<li><a href="../index.html"  id="tlinks" class="toplinks" >Homepage</a></li>
					<li><a href="featureNationalWonders.html" id="thold" class="toplinks"> Feature National Wonders</a></li>
					<li><a href="contact.html" id="linkhold" class="toplinks">Contact Us</a></li>
					<li><a href="register_user.html" id="phold" class="toplinks"> Sign Up</a></li>	
					<li><a href="login.html" id="loglinks" class="toplinks"> Login</a></li>
					<li><a href="aboutus.html" id="panlinks" class="toplinks"> About Us</a></li>
					
						
				</ul>	
					<form method="post" id="search"   action="..php/login.php" >
						<div>
							<input type="text" name="search" value=""/>
							<input type="submit" value="Search"/>
						</div>						
					</form>	
			</div>
			<br/><br/>
			<div id="contentArea">
				<form method="post" id="login_user" action="../php/login_user.php" accept-charset='UTF-8'>
					<fieldset>
						<legend> Login Details</legend><br/><br/>
							<label> Screen Name:</label>
							<input type="text" size="40" id="screenname"  name="screenname" /><br/><br/>
							<label> Password:</label>
							<input type="password" size="40" id="mypwd"   name="mypwd" /><br/><br/>
							
							<input type="button" name="login_user" value="Login" />   <input type="button" value="RESET" />
					
				
						 <p>
							<a href="http://validator.w3.org/check?uri=referer"><img
							  src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid XHTML 1.1" height="31" width="88" /></a>
						</p>
						<p>
							<a href="http://jigsaw.w3.org/css-validator/check/referer">
								<img style="border:0;width:88px;height:31px"
								src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
								alt="Valid CSS!" />
							</a>
						</p>
					</fieldset>
				</form>
			</div>
			<div id="footerFix"></div>
				<div id="footerbox">
						<div id="footer" >
							<div id="footerholder" >
								<ul>
									<li><a href="../index.html" class="toplinks" >Homepage</a></li>
									<li><a href="featureNationalWonders.html" class="toplinks"> Feature National Wonders</a></li>
									<li><a href="contact.html" class="toplinks">Contact Us</a></li>
									<li><a href="register.html" class="toplinks"> Sign Up</a></li>	
									<li><a href="login.html" class="toplinks"> Login</a></li>
									<li><a href="aboutus.html" class="toplinks"> About Us</a></li>
								</ul>
							</div>
						</div>	  
				</div>
		</div>
	</body>
</html>
Posted
Updated 29-Mar-19 21:36pm
Comments
Richard Deeming 4-Apr-19 14:32pm    
MD5 - Security[^]:
The security of the MD5 hash function is severely compromised. A collision attack exists that can find collisions within seconds ...

PHP
$sql= "SELECT * FROM login WHERE $screenname='$screenname' AND mypwd = MD5('$mypwd')";
                                 ^^^^^^^^^^^ this is not one of the database field

Not necessary a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
SQL Injection Prevention Cheat Sheet - OWASP[^]
How can I explain SQL injection without technical jargon? - Information Security Stack Exchange[^]
 
Share this answer
 
Comments
k5054 29-Mar-19 20:04pm    
Humor: [xkcd: Exploits of a Mom](https://xkcd.com/327/)
hi everyone

thanks for all of the help, i hve figure the proble, it was an error in the html code
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900