Jump to content

cybershit

New Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by cybershit

  1. no you are right SIR  its not very complicated but the syntax is really crazy for beginner ......

     but i have one last question please...

    $login_counter = $row['logins'] +1;
    
    //------your code ----------
    			
    $pdo_statement=$db->prepare("update tbl_user set logins=$login_counter where user_id=:userId");
    $result = $pdo_statement->execute(array(':userId' => $_SESSION['user_login']['user_id']));
             
    // ------my code  ---------
    
    $sql = $db->prepare("UPDATE tbl_user SET logins=$login_counter WHERE user_id = '".$_SESSION['user_login']['user_id']."';");
    $sql->execute();

    what is finally the difference in the point

    3 ) Never put variables into a query. That's why "prepare" is used.

    ?

  2. lol i got it....

    $pdo_statement=$db->prepare("update tbl_user set logins=7  WHERE user_id = '".$_SESSION['user_login']['user_id']."';");

    thank you SIR 🙂

     

    lol the syntax is sometimes little crazy xDD

  3. 	
    .............
    
    else if(empty($password)){
    		$errorMsg[]="please enter password";
    	}
    	else
    	{
    		try
    		{
    			$select_stmt=$db->prepare("SELECT * FROM tbl_user WHERE username=:uname OR email=:uemail");
    			$select_stmt->execute(array(':uname'=>$username, ':uemail'=>$email));
    			$row=$select_stmt->fetch(PDO::FETCH_ASSOC);
    			
    			if($select_stmt->rowCount() > 0)
    			{
    				if($username==$row["username"] OR $email==$row["email"])
    				{
    					if(password_verify($password, $row["password"]))
    					{
    						$_SESSION["user_login"] = $row["user_id"];
    					
    						//----------------
                            $pdo_statement=$db->prepare("update tbl_user set logins=7 where user_id=2");
            	            $result = $pdo_statement->execute();
    						//----------------
    
    						$loginMsg = "Successfully Login...";
    						header("refresh:2; welcome.php");
    
    					}
    					else

    hey guys iam starting to learn during this crysis php :-). I got stucked with this pdo style..... i like to count logins, i tryed and figured out i can use the id... but my  question is how  can replace this "where user_id=2" to get the specific ID for the current user login in? the count function i i know how to make the... first i want to know how to write the syntax  of this pdo......

    thank you :-)

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.