Re: Video#5
Posted: Thu Jun 24, 2010 3:21 pm
you could actually just watch the videos up to about 14 or so then I started putting code back in for download.
You will get a lot less errors and understand it better if you do it that way. Although I still suggest supplementing it with the book I linked a few posts back!hallsofvallhalla wrote:you could actually just watch the videos up to about 14 or so then I started putting code back in for download.
Code: Select all
<?php
include_once 'connect.php';
session_start();
if (isset($_POST['submit']))
{
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=strip_tags($password);
$password=md5($password);
$query = "select name,password from players where name='$player' and password='$password'";
$result = mysql_query($query) or die("Could not query players");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['player']=$player;
echo "<big>Logged in successfully<br>";
echo "<A href='battle.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password.<A href='login.php'>Try Again</a></big>";
}
}
?>Code: Select all
Notice: Undefined index: player in C:\wamp\www\tutorial\authenticate.php on line 7
Wrong username or password.Try AgainCode: Select all
<form method="POST" action="authenticate.php">
User Name <input type="text" name=player" size="21">
Password <input type="password" name="password" size="21" mask="x">
<br>
<input type="submit" value="Login" name="submit">Code: Select all
$query = "select name,password from players where name='$player' and '$password' ";Code: Select all
$query = "select name,password from players where name='$player' and password='$password' ";Code: Select all
<form method="POST" action="authenticate.php">
User Name <input type="text" name="player" size="21">
password <input type="password" name="password" size="34">
<br>
<input type="submit" value="Log-in" name="submit"></form>
Code: Select all
<?php
include_once 'connect.php';
session_start();
if (isset($_POST['Submit']))
{
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=strip_tags($password);
$password=md5($password)
$query = "select name,password from players where name='$player' and password='$password' ";
$result = mysql_query($query) or die ("Could not query players");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['player']=$player;
echo "<big>Logged in successfully!<br>";
echo "<a href='battle.php'>Continue></a></big>";
}
else
{
echo "<big>Login failed - Wrong username or password. <a href='login.php'> Try Again </a></big>";
}
}
?>