PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
kam
Forum Newbie
Posts: 8 Joined: Mon Aug 25, 2008 1:59 am
Post
by kam » Mon Aug 25, 2008 2:17 am
hi every one
i will write the code of login but when i up this code on my web sit i have the problem that say
Code: Select all
Fatal error: Call to undefined function IsValidUser() in /home/kamiti/public_html/LogiInto/Login.php on line 13
but i will write this function on DataAccess.php page
Code: Select all
<?
if ( phpversion() >= "4.2.0"){
extract($_POST);
extract($_GET);
extract($_SERVER);
extract($_COOKIE);
}
error_reporting(0);
$hostId="localhost";
$dbUser="root";
$dbPassword="123123";
$dbName="kamitidb";
mysql_pconnect($hostId,$dbUser,$dbPassword) or die ("íÊã ÊÍíË ÞÇÚÏÉ ÇáÈíÇäÇÊ");
mysql_select_db($dbName) or die ("áÇ ÊæÌÏ ÞÇÚÏÉ ÈíÇäÇÊ");
function IsValidUser($Account,$Password){
$query="select * from accounts where Account='".
$Account."'";// sure binary search will happen
$result=mysql_query($query);
$i=mysql_num_rows($result);
if($i>0){
$row=mysql_fetch_array($result);
if($row["Password"]==$Password){//case sensitive compare
return true; // correct acccount and password
}
else
return false;// correct account with false password
}
else
return false;// invalid account and password
}
function GetAccountType($account){
$query="select usertypes.type from accounts,usertypes
where typeid=usertypes.id and account='$account'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
return $row["type"];
}
?>
can any one help me
Last edited by
kam on Mon Aug 25, 2008 2:47 am, edited 1 time in total.
Ziq
Forum Contributor
Posts: 194 Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh
Post
by Ziq » Mon Aug 25, 2008 2:23 am
Can u show source login.php?
Maybe you forget use include() or require()
kam
Forum Newbie
Posts: 8 Joined: Mon Aug 25, 2008 1:59 am
Post
by kam » Mon Aug 25, 2008 2:49 am
this is page of login.php
Code: Select all
<? session_start();
include_once("../DataAccess.php");
if($action=="logout"){
session_start();
session_destroy();
echo "<CENTER><b><font color=\"#FF0000\" face=\"Tahoma\">?? ????? ??????</font></b></p>";
echo"<meta http-equiv='refresh' content='2;URL=Login.php'>";
exit();
}
if(isset ($_POST["txtUname"]) and isset($_POST["txtPassword"])){
// not new vistor (user submit the Page)
if(IsValidUser($_POST["txtUname"],$_POST["txtPassword"])){
$_SESSION["login"]="true";
$_SESSION["name"]=$_POST["txtUname"];
$_SESSION["role"]=GetAccountType($_POST["txtUname"]);
if($_GET["return"]!="")
header("location:".$_GET["return"]);
else
header("location:admin/");
echo $_GET["return"];
}
else{
$message="Invalid Username or Password.";
}
}
?>
<!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">
<head>
<title>:: ???? ?????? ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<meta name="Robots" content="index,follow" />
<meta name="keywords" content="????? ?????" />
<meta name="description" content="?????? ?????" />
<style type="text/css">
<!--
.style1 {font-family: Tahoma}
.style2 {
font-size: x-small;
font-weight: bold;
color: #0099FF;
}
.style3 {font-family: Tahoma; font-size: x-small; }
.style4 {font-family: "Hacen Saudi Arabia"}
.style5 {
color: #00CC00;
font-family: "Hacen Saudi Arabia";
}
.style7 {
font-family: Tahoma;
font-size: x-small;
color: #0099FF;
font-weight: bold;
}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0" background="../images/black.JPG">
<tr>
<td colspan="3" background="../images/heder.jpg"><div align="center" class="style5">????? ???? </div></td>
</tr>
<tr>
<td></td>
<td><? echo $message; ?></td>
</tr>
<tr>
<td height="24" background="../images/sidebar.jpg"><div align="center" class="style4"><span class="style7">??? ???????? </span></div></td>
<td><input name="txtUname" type="text" id="txtUname"/></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td background="../images/sidebar.jpg"><div align="center" class="style3 style1 style2">???? ?????? </div></td>
<td><input name="txtPassword" type="password" id="txtPassword" /></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="btnLogin" type="submit" id="btnLogin" value="????"/>
</div></td>
</tr>
</table>
</form>
</body>
</html>
and this is logout.php
Code: Select all
<?php
session_start();
ob_start();
unset($_SESSION["login"]);
unset($_SESSION["name"]);
unset($_SESSION["role"]); // unset all Session variable
session_destroy();// destory session
echo "<script type=\"text/javascript\">location.href='login.php'</script>";
?>
and this is thw index.php
Code: Select all
<?
session_start();
include("adminrole.php");
if($_POST["btnSignOut"]){
session_destroy();
header("location:../login.php");
}
echo "
<frameset cols = '80%,20%'>
<frame src='home.php?do=home' id='leftFrame' name='leftFrame'
width='80%' height='100%' frameborder='0' scrolling='yes' />
<frame src='nav.php' id='RightFrame' name='RightFrame'
width='20%' height='100%' frameborder='0' scrolling='yes' />
</frameset>
";
?>
Ziq
Forum Contributor
Posts: 194 Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh
Post
by Ziq » Mon Aug 25, 2008 9:14 am
It's very strange. Are u sure that DataAccess.php in folder /home/kamiti/public_html/LogiInto/?
Try to replace include_once() on require_once() in login.php
Code: Select all
require_once("../DataAccess.php");
kam
Forum Newbie
Posts: 8 Joined: Mon Aug 25, 2008 1:59 am
Post
by kam » Mon Aug 25, 2008 5:08 pm
the output
Code: Select all
Fatal error: Call to undefined function IsValidUser() in /home/kamiti/public_html/SecurePages/Login.php on line 12
i sure that this function is found on config file, and this code we work on the localhost why
kam
Forum Newbie
Posts: 8 Joined: Mon Aug 25, 2008 1:59 am
Post
by kam » Tue Aug 26, 2008 3:01 am
Code: Select all
Not Found
The requested URL /SecurePages/admin/index.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.8b DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.6 Server at http://www.kamiti.com Port 80