Need PHP Form with database connection code

Discussion in 'PHP' started by asit.ashmit, Jan 7, 2009.

  1. #1
    Hi,

    I Need PHP login Form with database connection code.

    Also i need session id different page.

    Suppose when a.htm page loading that time pages should be check session id. If it's there then it'll go b.htm neither redirect to c.htm.

    Kindly anybody suggest me for this code, i'll really appreciate with him.

    Thanks
    Alok
     
    asit.ashmit, Jan 7, 2009 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    Kaizoku, Jan 7, 2009 IP
  3. asit.ashmit

    asit.ashmit Banned

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3

    Please suggest me appropriate code. bcoz i'm beginner in php.
     
    asit.ashmit, Jan 7, 2009 IP
  4. Sangeetha.M

    Sangeetha.M Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <?php
    ob_start();
    session_start(); 
    $conn=mysql_connect("localhost","root","");
    mysql_select_db("login");
    if(isset($_POST['submit']))
    {
      $result=mysql_query("select * from registered_user 
      where username='" . $_POST['username'] . "' and password='" . $_POST['password'] . "'");
    $num=mysql_num_rows($result); 
    if($num < 1)
    {
     	 echo "You are not authenticated.  Please login.";
    }
    else
    {
    $_SESSION['username']=$_POST["username"];
    $_SESSION['password']=$_POST["password"];  
    header("location:wel.php");
    }
    }
    
    ?> 
    <form method="post" action="log.php">
    UserName:<input type="text" name="username"  /><br />
    Password:<input type="text" name="password" />
    
    <input type="submit" name="submit" value="Submit" />
    </form>
    PHP:
     
    Sangeetha.M, Jan 7, 2009 IP
  5. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #5
    If you're a beginner I wouldn't recommend login scripts until you've increased your abilities. The above post is littered with vulnerabilities and I would strongly recommend you do not use it.
     
    Danltn, Jan 7, 2009 IP