Click here to Skip to main content
15,070,828 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:

			// capture the values from the form and store in php variable
		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));
		if($rowcount ==1)
			echo"<script type=\"text/javascript\">
			alert('Screenname and password does not exist!');
			echo"<script type=\"text/javascript\">
			alert('Screenname and password does not exist!');

here is the htmml code
<pre><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 

<html xmlns="" xml:lang="en" lang="en">
		<title> Login </title>
		<link rel="stylesheet" type="text/css" href="../css/stylesheet.css" />
		<div id="container" >
			<div id="header">
				<img src="../images/header.jpg" alt="header" />
			<div id="navbar">
					<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>
					<form method="post" id="search"   action="..php/login.php" >
							<input type="text" name="search" value=""/>
							<input type="submit" value="Search"/>
			<div id="contentArea">
				<form method="post" id="login_user" action="../php/login_user.php" accept-charset='UTF-8'>
						<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" />
							<a href=""><img
							  src="" alt="Valid XHTML 1.1" height="31" width="88" /></a>
							<a href="">
								<img style="border:0;width:88px;height:31px"
								alt="Valid CSS!" />
			<div id="footerFix"></div>
				<div id="footerbox">
						<div id="footer" >
							<div id="footerholder" >
									<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>
Updated 29-Mar-19 21:36pm
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 ...

$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[^]
k5054 29-Mar-19 20:04pm
Humor: [xkcd: Exploits of a Mom](
hi everyone

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

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