Form Already Filled Out

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

 



Hello, Soooo i created a simple login system, and I am using sessions  Everything seems to work fine, however; when I upload my files to my server and type my domain name my index.php page comes up and the form is automatically filled out with a username and password. How do i make it empty when I initially enter the site, and yes I did create a logout.php file that destroys a session. Please help, it is hard to explain this when I cant show it in person. Thanks in advance!

Here is the login.php code, i didn't md5() the password yet:


<?php

if ($_SESSION['user'])
{
    header("Location: error.php");
    exit();
}
include('connect.php');
if ($_POST['login']){
   

$user=$_POST['user'];
$pass=$_POST['pass'];
$sql="SELECT * FROM members WHERE username='$_POST[user]' and password='$_POST[pass]'";
$result=mysql_query($sql, $con);
$count=mysql_num_rows($result);
if ($count==1){
  $_SESSION['user'] = $user;
  header('location: home.php');
}
else
    echo "<p style='color:red'>Wrong Username or Password</p>";
}

?>
<html>
    <head>
        <title></title>
        <link href="" rel="stylesheet" type="text/css" />
    </head>
    <body>
      
        <div id="main">
            <div id="menu">
                <ul>
                    <li>
                        <a href="">Home</a>
                    </li>
                    <li>
                        <a href="">Topix</a>
                    </li>
                    <li>
                        <a href="">Mission</a>
                    </li>
                </ul>
            </div>
            <div id='content'>
                <form method='post' action=''>
                    Username: <br/>
                    <input type='text' name='user' maxlength='30'/><br/>
                    Password: <br/>
                    <input type="password" name='pass' maxlength='30'/><br/>
                    <input type="submit" value="Log In!" name="login"/>
                </form>
                <a href=""> Register? </a>
               
        </div>
    </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