1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

login page..help

Discussion in 'PHP' started by psim, Dec 17, 2008.

  1. #1
    html code:
    <!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">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Login Page</title>
    <link rel="stylesheet" type="text/css" href="style/view_login.css" media="all">

    <body id="main_body" >
    <img src="images/top.png" alt="" width="502" height="9" id="top">
    <div id="form_container">
    <p align="center"><u>Log in</u>
    <p align="center">Please insert username and password:
    <form id="login" class="appnitro" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
    <div class="form_description">
    <div align="center">Username:
    <input type="text" name="username" size="10" />
    <br />
    <br />
    <input type="password" name="pass" size="10" />
    <br />
    <br />
    <input type="submit" value="Connect" />
    <p align="right"><input type="button" onClick="location.href='http://localhost/my_ptyxiakh/register.html'" value="Εγραφή" />


    php code:

    // Has a session been initiated previously?
    if (! isset($_SESSION['name'])) {
    // If no previous session, has the user submitted the form?
    if (isset($_POST['username']))
    $username = $_POST['username'];
    $pass = $_POST['pass'];
    // Connect to the PostgreSQL database
    $conn=pg_connect("host=localhost dbname=postgres
    user=postgres password=xxxxxxx")
    or die(pg_last_error($conn));

    // Look for the user in the users table.
    $query = "SELECT username FROM login
    WHERE username='$username' AND pass='$pass'";

    $result = pg_query($conn, $query);
    // If the user was found, assign some session variables.
    if (pg_num_rows($result) == 1)
    $_SESSION['name'] = pg_fetch_result($result,0,'name');
    echo"<META HTTP-EQUIV=\"REFRESH\" CONTENT= \"1;URL=http:.......\">";
    //$_SESSION['username'] = pg_fetch_result($result,0,'username');
    //echo "You're logged in";

    // If the user has not previously logged in
    } else {
    include "http://localhost/my_ptyxiakh/login.html";
    // The user has returned.
    } else {
    $name = $_SESSION['name'];
    echo "Welcome back, $name!";
    echo"<META HTTP-EQUIV=\"REFRESH\" CONTENT= \"1;URL=http:.......\">";

    I am trying to make a login page..but..
    Could you please tell me why this is not working..??
    this code it is not the whole mine so could you please tell me what is happening???
    psim, Dec 17, 2008 IP
  2. harrisunderwork

    harrisunderwork Well-Known Member

    Likes Received:
    Best Answers:
    Trophy Points:
    harrisunderwork, Dec 17, 2008 IP