Jump to content


New Members
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Morrolan

  • Rank
  1. To be clear, I want to use composer as I will be using third-party packages in my refactoring.
  2. Hi all, I am trying to implement PSR-4 autoloading in my project. It is an existing application I have inherited that doesn't use OOP, but I am hoping to refactor over time to use OOP, and PSR4 is crucial for me as it is a big task. At this present time we do not rely on any external libraries (old application entirely written in-house), so composer is ONLY being used for autoloading. First of all, I assume that the vendor dir needs to be present on the server/git repo for autoloading, as /vendor/autoload.php is required, even though the consensus is to add the vendor directory to .gitignore? My app structure on my server looks like this: composer.json: login.php calls authenticated.php when a user successfully logs in, and authenticated calls my init.php script which contains: <?php require_once('../../../vendor/autoload.php'); ?> it is search.php that has the error. The user is redirected to search.php when they are authenticated. search.php has the lines: use Framework\Helpers\OSHelpers; $current_os = OSHelpers::GetConciseOSFromUserAgent($user_agent); the static call to OSHelpers works fine if require_once is used. OSHelpers.php is namedspaced as: <?php namespace Framework\Helpers; The error I receive is: I'm at a bit of a loss about why it does this? When I follow the example in this video (https://www.youtube.com slash watch?v=VGSerlMoIrY) my example app works fine, but trying to replicate this in a slightly more complicated structure is giving me problems. Many thanks in advance, Morrolan
  3. Hi, I'm pretty new to php, having mostly worked with C#, Objective-C and Python. I am trying to write a basic script with 1 input box and 2 buttons. The first button I want to submit a password, and the hash is then printed to the page. My second button I want to verify the hash, and see if it matches what was submitted. If it does, I want it to print that it matches. Simple password form operation basically. However, my second button isn't working and I'm not sure why? $password_submitted = false; if ($_SERVER["REQUEST_METHOD"] == "POST") { $submitted_password = $_POST["password"]; } ?> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Password: <input type="password" name="password"> <br><br> <input type="submit" name="submit" value="Submit"> </form> <?php if ($submitted_password != "") { $hash = password_hash($submitted_password, PASSWORD_DEFAULT); echo "Password Hash: " . $hash; } ?> <br><br> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <input type="submit" name="submit" value="Compare Passwords"> </form> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($password_submitted == true) { verify_password($submitted_password, $hash); } } function verify_password($submitted_password, $hash) { if (password_verify($submitted_password, $hash)) { echo "Password match!\n"; } } ?> Is it because I am submitting to the same script twice? If so, how would one work around that limitation? Kind Regards, Morrolan
  • 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.