Results 1 to 19 of 19

Thread: PHP login ?!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    The Strat
    Join Date: Aug:2010
    Location:
    Posts: 189

    PHP login ?!



    , . , . - , .
    :
    1. "members", user- ;
    2. Index.php - ;
    3. checklogin.php - ;

    checklogin.php . , :
    <?php
    $host="localhost"; // Host name
    $username="somename"; // Mysql username
    $password="somepass"; // Mysql password
    $db_name="somename"; // Database name
    $tbl_name="members"; // Table name

    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");

    // username and password sent from form
    $myusername=$_POST['someuser'];
    $mypassword=$_POST['somepass'];

    // To protect MySQL injection (more detail about MySQL injection)
    $myusername = stripslashes($myusername);
    $mypassword = stripslashes($mypassword);
    $myusername = mysql_real_escape_string($myusername);
    $mypassword = mysql_real_escape_string($mypassword);

    $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
    $result=mysql_query($sql);

    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);
    // If result matched $myusername and $mypassword, table row must be 1 row

    if($count==1){
    // Register $myusername, $mypassword and redirect to file "login_success.php"
    session_register("myusername");
    session_register("mypassword");
    header("location:\design_\index.html");

    }
    else {
    echo "Wrong Username or Password";
    }
    ?>
    . , !
    !
    CPU: Athlon II X2 245/ MB: Asus M4A78LT-M LE/ RAM: Silicon Power 2 X 2 GB DDR3 1333MHz/ VIDEO: Integrated ATI Radeon 3000/ HDD: Hitachi Deskstar 500GB/PSU: SEASONIC S12 II Bronze-430GB/

  2. #2
    Registered User PlamenPenchev's Avatar
    Join Date: Mar:2009
    Location: -
    Posts: 627
    ( ). , (, ..)?

  3. #3
    ! vbTheKing's Avatar
    Join Date: Sep:2003
    Location:
    Posts: 4,138
    ?
    - htaccess. cPanel - :
    http://www.siteground.com/tutorials/...irectories.htm
    - :
    http://www.addedbytes.com/lab/passwo...with-htaccess/

    , : if($count==1){ :
    echo $sql; exit;
    , , , echo-.
    stripslashes , \ - .
    ''? * *
    - !
    ...

  4. #4
    Registered User morgoth_srs's Avatar
    Join Date: Mar:2004
    Location: Sofia
    Posts: 1,149
    username password? $count.
    : . : . : . : . : . : -. : -.

  5. #5
    The Strat
    Join Date: Aug:2010
    Location:
    Posts: 189
    Quote Originally Posted by vbTheKing View Post

    , : if($count==1){ :
    echo $sql; exit;
    , , , echo-.
    :
    SELECT * FROM members WHERE username='' and password=''
    CPU: Athlon II X2 245/ MB: Asus M4A78LT-M LE/ RAM: Silicon Power 2 X 2 GB DDR3 1333MHz/ VIDEO: Integrated ATI Radeon 3000/ HDD: Hitachi Deskstar 500GB/PSU: SEASONIC S12 II Bronze-430GB/

  6. #6
    ! vbTheKing's Avatar
    Join Date: Sep:2003
    Location:
    Posts: 4,138
    HTML-a index.php :
    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Login page</title>
    </head>
    <body>
    <form action="checklogin.php" method="post">
    User: <input type="text" value="" name="someuser">
    Pass: <input type="password" value="" name="somepass">
    </form>
    </body>
    </html>
    ''? * *
    - !
    ...

  7. #7
    The Strat
    Join Date: Aug:2010
    Location:
    Posts: 189
    : Wrong Username or Password

    index.php

    PHP Code:
    <body>
         <
    table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <
    tr>
    <
    form name="form1" method="post" action="checklogin.php">
    <
    td>
    <
    table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
    <
    tr>
    <
    td colspan="3"><div align="center"><strong> !!! </strong></div></td>
    </
    tr>
    <
    tr>
    <
    td width="78">Username</td>
    <
    td width="6">:</td>
    <
    td width="294"><input name="myusername" type="text" id="myusername"></td>
    </
    tr>
    <
    tr>
    <
    td>Password</td>
    <
    td>:</td>
    <
    td><input name="mypassword" type="text" id="mypassword"></td>
    </
    tr>
    <
    tr>
    <
    td>&nbsp;</td>
    <
    td>&nbsp;</td>
    <
    td><input type="submit" name="Submit" value="Login"></td>
    </
    tr>
    </
    table>
    </
    td>
    </
    form>
    </
    tr>
    </
    table
    CPU: Athlon II X2 245/ MB: Asus M4A78LT-M LE/ RAM: Silicon Power 2 X 2 GB DDR3 1333MHz/ VIDEO: Integrated ATI Radeon 3000/ HDD: Hitachi Deskstar 500GB/PSU: SEASONIC S12 II Bronze-430GB/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |