Still struggeling with my first script...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here are all the scripts original. It still won't work. I can't see what's
wrong with it???
It's from the tutorial PHP5 and Mysql for dummies..... I have shorted it
down though, since I am the only one who will register the User with a
password. What I did was removing the Switch at the beginning of the
loginscript(Guildlogin1.php) and change it with an if statement instead.
Don't think that is the problem though. I use php5 with MySql 4.1.7 on my
testingserver(Apache 2.0)

--------------------------------------
Register.php(this works):
------------------------------

<html>
<head>
<title>HOoSRegisterpage for new membersHOoS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheets/holyorder.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#000000">
<?php
include ("connections/HOoStest.php");



if (isset($_POST["MM_insert"]) && $_POST["MM_insert"] == "reg") {
$sql_reg = sprintf("INSERT INTO guildlogin (guilduser_name, guilduser_pass)
VALUES ('%s', '%s')",
$_POST['guilduser_name'],
md5($_POST['guilduser_pass'])); // If I change md5 with password. I get
undefined function password() in Register.php
$reg = mysql_query($sql_reg) or die(mysql_error());
}

?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200" align="center"><img src="guildimages/tabard.jpg"
alt="pic1"></td>
<td align="center">
<!--Mainlogo-->

<img src="guildimages/main_logo.jpg" alt="logo"></td>
<td width="200" align="center"><img src="guildimages/tabard.jpg"
alt="pic1"></td>
</tr>
<tr>
<td colspan="3" align="center">
<table>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<tr>
<td align="center" valign="middle" class="maintext">
New user:<input name="guilduser_name">
</td>
</tr>
<tr>
<td align="center" valign="middle" class="maintext">
Password:<input name="guilduser_pass" type="password"><br>
<input type="hidden" name="MM_insert" value="reg">
</td>
</tr>
<tr>
<td align="center" valign="middle" class="maintext">
<input name="submit" type="image" src="guildimages/register_btn.jpg"
value="update">
</td>
</tr>
</form>
</table>
</td>
</tr>

</table>

</body>
</html>
-------------------------------------------------
Guildlogin1.php
-------------------------------------------------
<?php
include ("connections/HOoStest.php");



session_start();
if (@$_GET['guildaction'] == "login")
{

$sql = "SELECT guilduser_name FROM guildlogin
WHERE guilduser_name='".$_POST['guilduser_name']."'";
$result = mysql_query($sql) or die("Couldn't execute query.");
$num = mysql_num_rows($result);
if ($num ==1) //loginname found
{
$sql = "SELECT guilduser_name FROM guildlogin
WHERE guilduser_name='".$_POST['guilduser_name']."'
AND guilduser_pass=md5('".$_POST['guilduser_pass']."')";

// if I change the md5() to password() I get an error saying: Undefined
function password() in Guildlogin.php.

 $result2 = mysql_query($sql) or die("Couldn't execute query 2.");
$num2 = mysql_num_rows($result2);
if ($num2 > 0) //password is correct
{
$_SESSION['auth']="yes";
$logname=$_POST['guilduser_name'];
$_SESSION['logname'] = $logname;
header("Location: HolyOrder1.php");
exit();
}
else //password is not correct
{
unset($guildaction);
$message="Login not correct";
header("Location: Guildloginerror.php");
}
}
elseif ($num == 0) // Wrong name. Name not in db
{
unset($guildaction);
$message="Login failed";
header("Location: Guildloginerror.php");
}

}

?>
----------------------------------------
form:
----------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd
">
<html>
<head>
<title>HOoSloginpage for membersHOoS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheets/holyorder.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#000000">





<table width="100%" border="0" cellspacing="0" cellpadding="0"
class="maintext">
<tr>
<td width="200" align="center"><img src="guildimages/tabard.jpg"
alt="pic1"></td>
<td align="center">
<!--Mainlogo-->

<img src="guildimages/main_logo.jpg" alt="logo"></td>
<td width="200" align="center"><img src="guildimages/tabard.jpg"
alt="pic1"></td>
</tr>
<tr>
<td colspan="3" align="center">


<table>
<form action="Guildlogin1.php?guildaction=login" method="post">
<?php
if (isset($message))
echo "$message";
?>
<tr>
<td align="center" valign="middle" class="maintext">
Login as:<input type=text name="guilduser_name">
</td>
</tr>
<tr>
<td align="center" valign="middle" class="maintext">
Password:<input type="password" name="guilduser_pass"><br>
</td>
</tr>
<tr>
<td align="center" valign="middle" class="maintext">
<input name="log" type="submit" src="guildimages/login_btn.jpg"
value="Enter"></td>
</tr>
</form>
</table>



</td>
</tr>

</table>

</body>
</html>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux