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\newhr\checklogin.php on line 14
plz help me to solve it......
Mainform.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>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</html>

checklogin

<?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

<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>

logout

<HTML>
<HEAD>
 <TITLE>logout</TITLE>
</HEAD>
<BODY>
  <?
session_start();
session_destroy();
?>

</BODY>
</HTML>

Recommended Answers

All 7 Replies

Hmm can't see any errors. What is the PHP version you are using ?

Apache server...MYsql database...........php version 2.22.....

Please create a test file with the following code and execute that.
Check which is the php version you are using.

mysql_real_escape_string() is available as of (PHP 4 >= 4.3.0, PHP 5)

<?php
phpinfo();
?>

this funcation will support only PHP 4 >= 4.3.0, PHP 5).

m using php 4.1.1 version.............

is there any another function to use which is supported by php 4.1.1......so that i can replace this function with other one....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.