Please can you show me where is the wrong in this programme

login form :eye:
<HTML>
<HEAD>
<TITLE>New Document</TITLE>
</HEAD>
<BODY>

<form action=“tes.php” method=“post”>

<label>userName: <input type=“text” name=“username” /></label><br />
<label>password: <input type=“text” name=“password” /></label><br />
<input type=“submit” value=“SUBMIT” />
</form>

<?php

$dbcnx = @mysql_connect(‘localhost’, ‘sura’, ‘lionlion’);
if (!$dbcnx) {
exit(‘<p>Unable to connect to the ’ .
‘database server at this time.</p>’);
}
// Select the jokes database
if (!@mysql_select_db(‘form’)) {
exit(’<p>Unable to locate the form ’ .
‘database at this time.</p>’);
}
// add it to the database.
if (isset($_POST[‘username’])) {
$username = $_POST[‘username’];
$sql = “INSERT INTO form SET
username=‘$username’,
password=‘password’”;
if (@mysql_query($sql)) {
echo ‘<p>Your username has been added.</p>’;
} else {
echo '<p>Error adding submitted joke: ’ .
mysql_error() . ‘</p>’;
}
$username=$_POST[‘username’]; //pretty sure POST has to be capital - I could be wrong though
$password=$_POST[‘password’];
if ($username==“dina” && $password==“lion”) { //no need for extra brackets inside unless you want to group logic together
echo “ok you can acsess!”;
}
else {
echo ‘<p> denied </p>’;
}

?>

</BODY>
</HTML>

What is the error that you’re experiencing?

Meanwhile, these are the problems that I notice with the above code.

[list][]Missing xhtml doctype (assuming xhtml from structure of input elements)
[
]HTML tags should normally be in lowercase
[]form action is for tes.php - should that be test.php ?
[
]form elements need to be contained within block-level elements, for unstyled compatibility. Wrap them with paragraph tags instead.
[]inappropriate break elements. use them only with poetry and addresses
[
]password isn’t retrieved from form, or set correctly in the sql statement[/list]

I copied and pasted your code into Firefox and an error showed with Missing closing brace.

Here is the amended code with some additions and corrections:


<!Doctype html5>
<html>
<head>
	<title>New Document</title>
	<style type='text/css'>
		fieldset {width:42%; margin:2em auto; background:#dff none; color:#00f}
	</style>	
</head>
<body>


	<form action="tes.php" method="post">
		
		<fieldset'>
			<legend>New Document </legend>
			
				<label>userName: </label>
				<input type="text" name="username" /><br />
				
				<label>password: </label>
					<input type="text" name="password" /><br />
				<input type="submit" value="SUBMIT" />
				
		</fieldset>		
		
	</form>

<?php
		$dbcnx = @mysql_connect('localhost', 'sura', 'lionlion');
		if (!$dbcnx)
		{
			exit('<p>Unable to connect to the ' . 'database server at this time.</p>');
		}
		
		// Select the jokes database
		if (!@mysql_select_db('form'))
		{
			exit('<p>Unable to locate the form ' 	.'database at this time.</p>');
		}
		
		// add it to the database.
		if (isset($_POST['username']))
		{
			$username = $_POST['username'];
			$sql = "INSERT INTO form SET
			username='$username',
			password='password'";
			if (@mysql_query($sql))
			{
				echo '<p>Your username has been added.</p>';
			} else {
				echo '<p>Error adding submitted joke: ' .
				mysql_error() . '</p>';
			}
			$username=$_POST['username']; //pretty sure POST has to be capital - I could be wrong though
			$password=$_POST['password'];
			if ($username=="dina" && $password=="lion") { //no need for extra brackets inside unless you want to group logic together
				echo "ok you can acsess!";
			}	else {
				echo '<p> denied </p>';
			}
		}// missing closing brace	
?>

</body>
</html>

.

oh thank you but can i ask you how can i open codes into firefox

oh i discovered by wamp it will appear into firefox

The correct doctype for HTML 5 is:

<!DOCTYPE html>

not

<!Doctype html5>

Whoops - point noted - I was in a hurry to got to lunch :slight_smile:

http://www.w3schools.com/html5/tag_doctype.asp

Tips and Notes

Note: The <!DOCTYPE> tag does not have an end tag.

Tip: The <!DOCTYPE> declaration is NOT case sensitive.

.