::::----PHP & Database sign in script problem ----::::

hey guys ,
i am having a problem to create a sign in form with my database ,this my code :

[php][php]<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "a_database";

mysql_connect($host,$user,$pass);
mysql_select_db($db);

if(isset($_POST['username'])){
	$username = $_POST['username'];
	$password = $_POST['password'];
	$sql = "SELECT *FROM enseignant WHERE mail_enseignant=".$username." AND Mot_de_passe=".$pass." LIMIT 1 ";
	$res = mysql_query($sql);
	if (@mysql_num_rows($res) == 1){
		require("note_on.php");
		}else{
			echo "Check your Email or your Password and re-Sign In thanks.";
		}
		}
?>
<<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN" dir="ltr">
<head >
<title>Département Math-Info | Note Tab</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="imagetoolbar" content="no" />
<link rel="stylesheet" href="styles/layout.css" type="text/css" />
<!-- 3 Column Stylesheet Added To The Page And Not To The Layout.css -->
<link rel="stylesheet" href="styles/3_column.css" type="text/css" />
</head>
<body id="top">
<div class="wrapper row1">
  <div id="header" class="clear">
    <div class="fl_left">
      <h1><a href="index.php">Département Math-Info </a></h1>
      <p>Just pour vous</p>
    </div>
    <form action="#" method="post" id="login">
      <fieldset>
	  <h6>Ensignant Login</h6>
        <legend>Ensignant Login</legend>
        <input type="password" name="password" />
        <input type="text" name="username" />
        <div id="forgot">Need <a href="#">Help ?</a> or <a href="#">Forgot Your Details ?</a></div>
        <input type="image" src="images/sign_in.gif" id="signin" alt="Sign In" />
      </fieldset>
    </form>
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper row2">
  <div id="topnav">
    <ul>
      <li><a href="index.php">Homepage</a></li>
      <li><a href="contact-us.php">CONTACT US</a></li>
      <li><a href="nouveauté.php">NOUVEAUTé</a></li>
  
      <li class="active"><a href="note-off.php">Note Tab</a></li>
      <li class="last"><a href="gallery.php">Gallery</a></li>
    </ul>
    <div  class="clear"></div>
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper row4">
  <div id="container" class="clear">
    <!-- ####################################################################################################### -->
    <div id="left_column">
      <div class="holder">
        <h2 class="title">Quick Links</h2>
        <ul class="nostart">
          <li><a href="contact-us.html">Contact Us</a></li>
            <li><a href="#">Nouveauté</a></li>
            <li><a href="#">Spéciality</a></li>
            <li><a href="#">Math &amp; Informatique</a></li>
            <li><a href="#">2em Math</a></li>
            <li><a href="#">3em Math</a></li>
            <li><a href="#">2em Informatique</a></li>
            <li><a href="#">3em Informatique</a></li>
            <li><a href="#">Student Login</a></li>
            <li><a href="#">Ensignant Login</a></li>
            <li><a href="#">Online Courses</a></li>
            <li><a href="#">Gallery</a></li>
        </ul>
      </div>
      <div class="holder">
        <h2 class="title">Lorem ipsum dolor</h2>
        <div class="imgholder"><img src="images/demo/190x90.gif" alt="" /></div>
        <div class="imgholder last"><img src="images/demo/190x90.gif" alt="" /></div>
      </div>
    </div>
    <!-- ############ -->
    <div id="content">
		<p>You Must login to see this Content : <p>
 
      
		 </div>
    <!-- ############ -->
    <div id="right_column">
      <div class="holder">
        <h2 class="title">Definition Of The Note-Tab </h2>
        <p>This Tab is used to Display Notes of TD TP & Exam .</p>

        <p>To Be Able to see what in this tab <a href="note-off.html">NOTE-TAB</a> you must login through the login area Above ,if u are
		Ensignant you have to use your Email and Password to log-in ,or if you're a Student u can use your Matricule Thanks. </p>
        <p class="readmore"><a href="#">Continue Reading &raquo;</a></p>
      </div>
      <div class="holder">
        <h2 class="title">Publicity</h2>
        <div class="imgholder"><img src="images/demo/240x90.gif" alt="" /></div>
        <div class="imgholder"><img src="images/demo/240x90.gif" alt="" /></div>
        <div class="imgholder last"><img src="images/demo/240x90.gif" alt="" /></div>
      </div>
    </div>
    <!-- ####################################################################################################### -->
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper row5">
  <div id="footer" class="clear">
    <!-- ####################################################################################################### -->
    <div class="foot_contact">
      <h2>University Name Here</h2>
      <address>
      Address Line 1<br />
      Address Line 2<br />
      Town/City<br />
      Postcode/Zip
      </address>
      <ul>
        <li><strong>Tel:</strong> xxxxx xxxxxxxxxx</li>
        <li><strong>Fax:</strong> xxxxx xxxxxxxxxx</li>
        <li class="last"><strong>Email:</strong> <a href="#">[email protected]</a></li>
      </ul>
    </div>
    <div class="footbox">
      <h2>Administration</h2>
      <ul>
        <li><a href="#">Disclaimer</a></li>
        <li><a href="#">Accessibility</a></li>
        <li><a href="#">Freedom of Information</a></li>
        <li><a href="#">Website Privacy</a></li>
        <li><a href="#">Press Release Information</a></li>
        <li><a href="#">Annual Report</a></li>
        <li><a href="#">Financial Statements</a></li>
        <li><a href="#">Job Vacancies</a></li>
        <li class="last"><a href="#">Semester Dates</a></li>
      </ul>
    </div>
    <div class="footbox">
      <h2>Link Block 2</h2>
      <ul>
        <li><a href="#">Schools and Colleges</a></li>
        <li><a href="#">Student Activities</a></li>
        <li><a href="#">Student Affairs</a></li>
        <li><a href="#">Student Development</a></li>
        <li><a href="#">Student Financial Services</a></li>
        <li><a href="#">Student Group Directory</a></li>
        <li><a href="#">Student Life</a></li>
        <li><a href="#">International Students</a></li>
        <li class="last"><a href="#">Global Learning</a></li>
      </ul>
    </div>
    <div class="footbox last">
      <h2>Link Block 3</h2>
      <ul>
        <li><a href="#">Academic Advisory</a></li>
        <li><a href="#">Academic Assistance</a></li>
        <li><a href="#">Academic Calendars</a></li>
        <li><a href="#">Academics Office</a></li>
        <li><a href="#">Administration</a></li>
        <li><a href="#">Adult Learners</a></li>
        <li><a href="#">Alumni Chapters</a></li>
        <li><a href="#">Alumni Events</a></li>
        <li class="last"><a href="#">Residential Colleges</a></li>
      </ul>
    </div>
    <!-- ####################################################################################################### -->
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper">
  <div id="copyright" class="clear">
    <p class="fl_left">Copyright &copy; 2013 - All Rights Reserved - <a href="#">Domain Name</a></p>
    <p class="fl_right">Template by <a href="http://www.os-templates.com/" title="Free Website Templates">OS Templates</a></p>
  </div>
</div>
</body>
</html>?>[/php][/php]

this is my database :
Id_Enseignant = 14
Nom_Enseignant = hh
Prenom_Enseignant = hhs
mail_enseignant = hhss
Mot_de_passe = js4

i am really confused please help me thanks in advance !:

First off, you are using obsolete Mysql code. You need to use PDO or MYSQLI. There is a link in my signature to a basic PDO database to get you up and running.

Another thing, dont use @ to hide errors unless you have some custom function to handle the error. Get up and running with PDO. If you are still having problems come back and we will be happy to help you.

  • And don’t forget to specify what the problem is. We don’t always have time to try and guess what you already know.
Sponsor our Newsletter | Privacy Policy | Terms of Service