Login window using php

i m trying to make login page … while runing that i got one Fatal error i m not able to understand even i tried … guide me plz
here is :----
Fatal error: Call to undefined function: mysql_real_escape_string() in c:\apache\htdocs
ewhr\checklogin.php on line 14
plz help me to solve it…
LoginForm.html

[code=html]
<html>
<body bgcolor=“E6E6FA”>
<table width=“300” border=“0” align=“center” cellpadding=“0” cellspacing=“1” bgcolor=“#fffff”>
<tr>
<form name=“form1” method=“post” action=“checklogin.php”>
<td>
<table width=“100%” border=“0” cellpadding=“3” cellspacing=“1” bgcolor=“FAFAFA”>
<tr>
<td colspan=“3”><strong>Member Login </strong></td>
</tr>
<tr>
<td width=“78”>Username</td>
<td width=“6”>:</td>
<td width=“294”><input name=“username” type=“text” id=“username”></td>
</tr>
<tr>
<td>Password</td>
<td>: </td>
<td><input name=“password” type=“password” id=“password”></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type=“submit” name=“Submit” value=“Login”></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</html>


[SIZE="5"] checklogin.php[/SIZE]
[code=php]
<?php

$host="localhost";
$username="root";
$password="root";
$db_name="master";
$tbl_name="member";
$con=mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$username=$_POST['username'];
$password=$_POST['password'];
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM $tbl_name WHERE username='$username' and  password='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("username");
session_register("password");
header("location:loginsucess.php");
}
else {
echo "Wrong Username or Password";
}
mysql_close($con);
?>


loginsucess.php

[code=php]
<HTML>
<HEAD>
<TITLE>New Document</TITLE>
</HEAD>
<BODY>
<?
session_start();
if(!session_is_registered(username))
{
header(“location:loginform.html”);
}
?>

<html>
<body>
Login Successful
</body>
</html>


[SIZE="5"] Logout.php[/SIZE]
[code=php]
<HTML>
<HEAD>
 <TITLE>logout</TITLE>
</HEAD>
<BODY>
  <?
session_start();
session_destroy();
?>

</BODY>
</HTML>

I think you are using older version of PHP. Try ugrading to PHP5 and it should work.

I’d say quite contrary :slight_smile:
It will work in case of downgrade only.
this code needs to be rewritten or replaced

m using php 2.22 version…

2.2 ? Really? Update it ASAP. infact do it as soon as you read it :slight_smile:

mcastu, you have to enable mysql support in the php.ini

Call to undefined function: mysql_real_escape_string()

It’s only been in php since 4.3, are you really using 2.2??

hi
i have already made my project using 2.2…i learn php by doing self study.so dont have much knowledge about it…thats why i m using this version…now how can i make login winow in 2.2???hlp me out…now guide me what to do next…

ok.thankz for ur advice…

2.2 is much more like Apache version :slight_smile: