Jump to content

thilakan

Members
  • Posts

    20
  • Joined

  • Last visited

Posts posted by thilakan

  1. I am building cooking website. If the users want to check the price of the ingredients in different supermarkets they can do so.

    Button one for supermarket one

    Button two for supermarket two

     

    Once the click button; it will show the ingredients list with the current price.

    How would I go about doing this?

    1. How do I get the current price from the supermarket?
    2.  Do I need to get permission from the supermarket?

     

    Check this web site

    http://www.jamieoliver.com/recipes/vegetables-recipes/corn-chowder-with-a-homemade-chilli-cracker/

     

    THANK YOU

    post-171982-0-87885800-1413884441_thumb.jpg

  2. $ error = trim( strip_tags($_GET['error']) );
    VS
    $strip_error = strip_tags($_GET['error']) ;
    $trim_error = trim($strip_error);
    
    

    Which method is correct way?

    Also  I am first striping and trimming is it wright way.

     

    could you please advice me.

     

    Thank you

  3.  PDO-Prepared Statements using mysqli_real_escape_string

    Is it a good Idea to use mysqli_real_escape_string  for extra  security  In the Prepared Statements

    <?php
    
    	try {
          
    	  require_once '../includes/pdo_connect.php';
          $make = mysqli_real_escape_string($_GET['make']);
          $sql = 'SELECT *
                    FROM cars
                    WHERE make LIKE :make AND yearmade >= :yearmade AND price <= :price
                    ORDER BY price';
            $stmt = $db->prepare($sql);
            $stmt->bindValue(':make', '%' . $make . '%');
            $stmt->bindParam(':yearmade', $_GET['yearmade'], PDO::PARAM_INT);
            $stmt->bindParam(':price', $_GET['price'], PDO::PARAM_INT);
            $stmt->execute();
            $errorInfo = $stmt->errorInfo();
            if (isset($errorInfo[2])) {
                $error = $errorInfo[2];
            }
        } catch (Exception $e) {
            $error = $e->getMessage();
        }
    
    
  4. Undefined  error

    Why I am getting this error?

     

    What I am trying archive - 

           I want to get the client location and stored in the database

     

    Please advise me.

    Thank you.

    <!DOCTYPE html>
    <html>
    <body>
    
    
    <script>
    
    
    function geoFindMe() {
      var output ;
    
      if (!navigator.geolocation){
         output.innerHTML = "<p>Geolocation is not supported by your browser</p>";
        return;
      } else {
    
      function success(position) {
        var latitude  = position.coords.latitude;
        var longitude = position.coords.longitude;
    
         return(output.innerHTML = '<p>Latitude is ' + latitude + '° <br>Longitude is ' + longitude + '°</p>');
    
      };
    
      function error() {
        output.innerHTML = "Unable to retrieve your location";
      };
    
    
      navigator.geolocation.getCurrentPosition(success, error);
      
      }
    }
    
    var x = geoFindMe();
    alert(x);
    </script>
    
    </body>
    </html>
    
    
  5. Thank you for your answer. 

    Now I am going to place the password_needs_rehash code in the login file.

    My code looks like this:

    if (password_verify('password', $hash)) {

        echo 'Password is valid!';

    //  CHECK TO SEE PASSWORD NEED REHASH

    if (password_needs_rehash($hash, $algorithm, $options)) {

                $hash = password_hash($password, $algorithm, $options);

                /* Store new hash in db */

            }

    } else {

        echo 'Invalid password.';

    }?>

    Is this the right method ?

     

    Here, am I supposed to rehash the old password stored in the database or should I ask the user to enter a new password?

  6. When to use password_needs_rehash

     Workflow for account registration.

    1.       The user creates an account.

    2.       Their password is hashed password_hash($password, PASSWORD_DEFAULT) and stored in the database.

    3.       When the user attempts to login, the hash (password_verify  ) of the password they entered is checked against the hash of their real password (retrieved from the database).

    4.       If the hashes match, the user is granted access. If not, the user is told they entered invalid login credentials.

    My question is

    1.       When should I call password_needs_rehash?

    2.       Do I really need to use it? 

     

     

  7. <?php 
    	function cryptPass($input, $rounds = 9){
    	
    		$salt = "";
    	
    		$saltChars = array_merge(range('A','Z'), range('a','z'), range(0,9));
    	
    		for($i = 0; $i < 22; $i++){
    	
    			$salt .= $saltChars[array_rand($saltChars)];
    	
    		}
    		
    		return crypt($input, sprintf('$2y$%02d$', $rounds) . $salt);
    	
    	}
    
    	echo $inputPass = "password2";
    
    	echo $pass = "password";
    
    	$hashedPass = cryptPass($pass);
    
    	echo $hashedPass;
    
    	if(crypt($inputPass, $hashedPass) == $hashedPass){
    	
    		echo "<br /><h1>Password is a match = log user in</h1>";
    	
    	}else{
    	
    		echo "<br />Password does not match = do not log in";
    	
    	}
    ?>
    

    My PHP version 5.2

    When I run above code I am getting the password match answer. I should have get error message.

    Can anyone advise me .

    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.