Php Basic Code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ls101
    Confirmed User
    • Nov 2012
    • 713

    #1

    Php Basic Code

    Code:
    <?php
    
    #host = "localhost";
    #user = "root";
    #pass = "pass";
    #db = "test";
    
    mysql_connect(#host, #user, #pass);
    mysql_select_db(#db);
    
    if (isset($_POST['username'])) {
    	$username = $_POST['username'];
    	$password = $_POST['password'];
    	$sql = "SELECT " FROM users WHERE username='".#user."' AND password='".#pass."' LIMIT 1";
    	#res = mysql_query($sql);
    if (mysql_num_rows(#res) == 1) {
    	echo "You have successfully logged in";
    	exit();
    } else {
    	echo"Invalid Log In information. Please return to the previous page.";
    	exit();
    }
    ?>

    What is wrong with this code? Can't figure it out!
  • KillerK
    Confirmed User
    • May 2008
    • 3406

    #2
    you are missing }

    before the 2nd if

    Comment

    • Vapid - BANNED FOR LIFE
      Barterer
      • Aug 2004
      • 4864

      #3
      Sql injection has gotten very advanced...

      Comment

      • freecartoonporn
        Confirmed User
        • Jan 2012
        • 7683

        #4
        Originally posted by ls101
        Code:
        <?php
        
        #host = "localhost";
        #user = "root";
        #pass = "pass";
        #db = "test";
        
        mysql_connect(#host, #user, #pass);
        mysql_select_db(#db);
        
        if (isset($_POST['username'])) {
        	$username = $_POST['username'];
        	$password = $_POST['password'];
        	$sql = "SELECT " FROM users WHERE username='".#user."' AND password='".#pass."' LIMIT 1";
        	#res = mysql_query($sql);
        if (mysql_num_rows(#res) == 1) {
        	echo "You have successfully logged in";
        	exit();
        } else {
        	echo"Invalid Log In information. Please return to the previous page.";
        	exit();
        }
        ?>

        What is wrong with this code? Can't figure it out!
        shitloads of corrections/improvements can be made....

        ref: http://www.w3schools.com/php/func_my...ape_string.asp
        SSD Cloud Server, VPS Server, Simple Cloud Hosting | DigitalOcean

        Comment

        • Paul&John
          Confirmed User
          • Aug 2005
          • 8643

          #5
          why is there #user instead of $user ?
          Use coupon 'pauljohn' for a $1 discount at already super cheap NameSilo!
          Anal Webcams | Kinky Trans Cams Live | Hotwife XXX Tube | Get your Proxies here

          Comment

          • freecartoonporn
            Confirmed User
            • Jan 2012
            • 7683

            #6
            Originally posted by Paul&John
            why is there #user instead of $user ?
            i thought its new way of declaring vars in latest php ....
            duh.. me
            SSD Cloud Server, VPS Server, Simple Cloud Hosting | DigitalOcean

            Comment

            • Paul&John
              Confirmed User
              • Aug 2005
              • 8643

              #7
              Originally posted by freecartoonporn
              i thought its new way of declaring vars in latest php ....
              duh.. me
              it is?
              Use coupon 'pauljohn' for a $1 discount at already super cheap NameSilo!
              Anal Webcams | Kinky Trans Cams Live | Hotwife XXX Tube | Get your Proxies here

              Comment

              Working...