web site help

sudu hawa

Well-known member
  • Dec 1, 2011
    1,630
    100
    63
    machanla mama web ekak design kara eke login wena code eka me thiyenne

    <?php
    $username = "root";
    $password = "";
    $hostname = "localhost";
    $con=mysql_connect($hostname,$username,$password) ;
    $select = mysql_select_db("shopping cart", $con);
    $result = mysql_query("select email,Password FROM register");
    while ($row = mysql_fetch_array($result)) {

    $u1= $row{'email'};
    $p1=$row{'Password'};

    }
    $user=$_POST['txtemail'];
    $pass=$_POST['txtPassword'];
    if ($user == $u1 && $pass ==$p1 )
    {
    echo "Welcome " . $user;

    }
    else
    {
    header( 'Location: Login error.php' ) ;
    }

    ?>

    login unama page 4k 5k thiyenwa awata echo "Welcome " . $user; Welcome User Name eka anithe page walata add karaganne kohomadaaaaa plz help meee
     

    bonney777

    Active member
  • Oct 11, 2008
    374
    26
    28
    If login is success set the username to session variable
    example

    if ($user == $u1 && $pass ==$p1 )
    {
    echo "Welcome " . $user;

    session_start();
    $_SESSION['username'] = $user;

    }

    Thats all, now you can access the session in all pages.
    like this

    Start the session at the top of all pages

    <?php
    session_start() ;
    echo "Welcome : ".$_SESSION['username'];
    ?>

    Note - Dont forget to clear the session when the user is logout.
    session_destroy();
     

    sudu hawa

    Well-known member
  • Dec 1, 2011
    1,630
    100
    63
    If login is success set the username to session variable
    example

    if ($user == $u1 && $pass ==$p1 )
    {
    echo "Welcome " . $user;

    session_start();
    $_SESSION['username'] = $user;

    }

    Thats all, now you can access the session in all pages.
    like this

    Start the session at the top of all pages

    <?php
    session_start() ;
    echo "Welcome : ".$_SESSION['username'];
    ?>

    Note - Dont forget to clear the session when the user is logout.
    session_destroy();


    pahadili madi sampura code eka mokada machan ?????
     

    Welusumana

    Well-known member
  • Aug 16, 2010
    2,108
    154
    63
    why would I tell you
    If login is success set the username to session variable
    example

    if ($user == $u1 && $pass ==$p1 )
    {
    echo "Welcome " . $user;

    session_start();
    $_SESSION['username'] = $user;

    }

    Thats all, now you can access the session in all pages.
    like this

    Start the session at the top of all pages

    <?php
    session_start() ;
    echo "Welcome : ".$_SESSION['username'];
    ?>

    Note - Dont forget to clear the session when the user is logout.
    session_destroy();


    me kiyala tiyena vidiya hari.e vidiyata karapa.mona hari terenne nathnam ahapan.
     

    bonney777

    Active member
  • Oct 11, 2008
    374
    26
    28
    pahadili madi sampura code eka mokada machan ?????

    Insert the following codes in your script.

    <?php
    $username = "root";
    $password = "";
    $hostname = "localhost";
    $con=mysql_connect($hostname,$username,$password) ;
    $select = mysql_select_db("shopping cart", $con);
    $result = mysql_query("select email,Password FROM register");
    while ($row = mysql_fetch_array($result)) {

    $u1= $row{'email'};
    $p1=$row{'Password'};

    }
    $user=$_POST['txtemail'];
    $pass=$_POST['txtPassword'];
    if ($user == $u1 && $pass ==$p1 )
    {
    echo "Welcome " . $user;
    session_start();
    $_SESSION['username'] = $user;

    }
    else
    {
    header( 'Location: Login error.php' ) ;
    }

    ?>

    Thats all..

    In your other pages add this code in the place you want to get show the username

    <?php
    session_start() ;
    echo "Welcome : ".$_SESSION['username'];
    ?>
     

    BLACKLIST_MEMBER

    Well-known member
  • Feb 9, 2008
    37,854
    14,813
    113
    127.0.0.1
    eka mama ahapu ekata adala na machan thanks
    :yes: wadagath wei kiyala damme. naththan oyage oya thiyena login ekata passwords nogaha log wenna puluwan nisa sql injection eken.

    oyaage kathaawata uththare thiyenawa pahadiliwa 2nd video eke machan, session eken karanna puluwan oya wade :)
     
    Last edited:

    sudu hawa

    Well-known member
  • Dec 1, 2011
    1,630
    100
    63
    Insert the following codes in your script.

    <?php
    $username = "root";
    $password = "";
    $hostname = "localhost";
    $con=mysql_connect($hostname,$username,$password) ;
    $select = mysql_select_db("shopping cart", $con);
    $result = mysql_query("select email,Password FROM register");
    while ($row = mysql_fetch_array($result)) {

    $u1= $row{'email'};
    $p1=$row{'Password'};

    }
    $user=$_POST['txtemail'];
    $pass=$_POST['txtPassword'];
    if ($user == $u1 && $pass ==$p1 )
    {
    echo "Welcome " . $user;
    session_start();
    $_SESSION['username'] = $user;

    }
    else
    {
    header( 'Location: Login error.php' ) ;
    }

    ?>

    Thats all..

    In your other pages add this code in the place you want to get show the username

    <?php
    session_start() ;
    echo "Welcome : ".$_SESSION['username'];
    ?>

    machan oya dipu eka a page ekata dala baluwa athe hariyanne na
    <?php
    $username = "root";
    $password = "";
    $hostname = "localhost";
    $con=mysql_connect($hostname,$username,$password) ;
    $select = mysql_select_db("shopping cart", $con);
    $result = mysql_query("select email,Password FROM register");
    while ($row = mysql_fetch_array($result)) {

    $u1= $row{'email'};
    $p1=$row{'Password'};

    }
    $user=$_POST['txtemail'];
    $pass=$_POST['txtPassword'];
    if ($user == $u1 && $pass ==$p1 )
    {
    echo "Welcome " . $user;
    session_start();
    $_SESSION['username'] = $user;

    }
    else
    {
    header( 'Location: Login error.php' ) ;
    }

    ?>

    moko karanneeeee
     

    sudu hawa

    Well-known member
  • Dec 1, 2011
    1,630
    100
    63
    :yes: wadagath wei kiyala damme. naththan oyage oya thiyena login ekata passwords nogaha log wenna puluwan nisa sql injection eken.

    oyaage kathaawata uththare thiyenawa pahadiliwa 2nd video eke machan, session eken karanna puluwan oya wade :)

    MACHAN TAHNKS E VIDEO EKA NAM MARA WATINWA...

    help ekak dennawada machan plz mata wadiya oya patha tharanne na