Jump to content
Larry Ullman's Book Forums

All Activity

This stream auto-updates     

  1. Today
  2. Yesterday
  3. You should debug the query itself to start. See if the query is returning exactly one row or not. If not, then you need to debug it backwards to see if the problem is: The value of $e in the PHP script The value of email in the database If active has a null value in the database (not an empty value)
  4. Where does the code sit that actually prevents someone from logging in if they are not set to accept cookies? I would like to remove that and see if that is the differece? I have been using your code for years and have older sites with the login.inc.php coding in the includes folder. They always worked. i guess I could go back to that but I would like to use the most updated coding available.
  5. Last week
  6. This part of the login code does not seem to be working. I know the information is in the database and the activation field says NULL. I believe that the browser - Firefox on a Mac - is accepting cookies. I have tried this with several users and they all have the same password. I am getting the error message that indicates that the Email and Password does not match those on file. I am set up to use PHP 7. // Query the database: $q = "SELECT user_id, first_name, user_level, pass FROM users WHERE email='$e' AND active IS NULL"; $r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n<br>MySQL Error: " . mysqli_error($dbc)); if (@mysqli_num_rows($r) == 1) { // A match was made. // Fetch the values: list($user_id, $first_name, $user_level, $pass) = mysqli_fetch_array($r, MYSQLI_NUM); mysqli_free_result($r);
  7. Hello! First, just so you know, these forums aren't that active. I check them three days a week myself. So going forward you should assume it'll take at least a couple of days to get a reply. As for your specific issue, I've been working with PHP for 20 years now and I've never heard of that error before. What is the exact URL you're loading when you see that error and what is the exact error? Finally, do keep in mind that this book assumes solid comfort with PHP and MySQL and builds upon that knowledge to create a couple of advanced e-commerce applications. If you're not truly comfortable with both technologies, you may want to start with a different book first.
  8. // Are we live? if (!defined('LIVE')) DEFINE('LIVE', false); // Errors are emailed here: DEFINE('CONTACT_EMAIL', 'you@example.com'); // ************ SETTINGS ************ // // ********************************** // // ********************************** // // ************ CONSTANTS *********** // // Determine location of files and the URL of the site: define ('BASE_URI', 'C:\xampp\htdocs\ecommerce1\ex1\.'); define ('BASE_URL', 'http://localhost/ecommerce1/ex1/'); define ('PDFS_DIR', BASE_URI . 'pdfs/'); // Added in Chapter 5. define ('MYSQL', BASE_URI . 'mysql.inc.php'); my file location C:\xampp\htdocs\ecommerce1\ex1 when run test file nothing show , error msg :Test file for the selected source file was not found. config.inc.php
  9. It looks like the function is defined twice in the same file, starting on lines 28 and 33.
  10. I believe that I have followed the code to create a "Forget Password" link. However, I am getting an error that seems to indicate that I am asking for a password hash twice - Fatal error: Cannot redeclare get_password_hash() (previously declared in /hermes/bosnacweb04/bosnacweb04aj/b717/nf.xxxxxxxxxxxx/public_html/xxxxxxxxxxxx/TBRMobile/mysqli.inc.php:28) in /hermes/bosnacweb04/bosnacweb04aj/b717/nf.xxxxxxxxxx/public_html/xxxxxxx/TBRMobile/mysqli.inc.php on line 33 ---- I have x'd out certain areas of this error on purpose. My config file and mysqli file are almost exact. I do not use a header file.
  11. I had the same problem and I found that I had the BASE_URL set incorrectly in module config.inc.php Once I fixed that the activation script ran OK.
  12. Earlier
  13. I am also having a similar type of problem but not in all instances. I am testing on a live site. MOST of the time the email will get the activation link but when I click the link I get the message saying that the account could not be activated. BUT the information is in the database and the column says, "NULL".
  14. I think I got it, I got some mess in those scripts, cannot keep track of them somehow. Wrong script, but it was working and then it quit, that is why I got confused, the later scripts do have a different setup and so easy to get carried away with the implementation that should be using different script.
  15. I do NOT understand this: "password_verify($p, $row['passward'])" where: $p = 123456 while this is in DB: ba3253876aed6bc22d4a6ff53d8406c6ad864195ed144ab5c87621b6c233b548baeae6956df346ec8c17f5ea10f35ee3cbc514797ed7ddd3145464e2a0bab413 ??? if (empty($errors)) { // If everything's OK. $q = "SELECT user_id, first_name, passward FROM users WHERE user='xyz' AND passward=SHA2('$p', 512)"; $r = mysqli_query($dbc, $q); // Run the query. // Check the result: if (mysqli_num_rows($r) == 1) { // Fetch the record: $row = mysqli_fetch_array($r, MYSQLI_ASSOC); // Return true and the record: // Check the password: if (password_verify($p, $row['passward'])) { unset($row['passward']); return [true, $row]; } else { $errors[] = 'The user name and password do not match those on file.'; } // - The user name and password entered do not match those on file. ???? } else { // Not a match! $errors[] = 'The user-name and password entered do not match those on file.'; }
  16. I found this link https://codeburst.io/insert-with-select-statement-for-columns-with-foreign-key-constraint-in-mysql-with-examples-f9ab57c8e4dd and fixing some of the errors in my query I got it working.
  17. Which table do I insert to first, table1 that does have the FOREIGN KEY (file_id) REFERENCES userinfo(user_id) or the table2 that does NOT have the constrain? I am trying to insert into both tables at a sequence, table1 and then table2, BUT I get this error: "Cannot add or update a child row: a foreign key constraint fails...!" Should I insert first into table2 and then into table1? Thanks $q1 = "INSERT INTO table1 ... $r1 = @mysqli_query($dbc, $q1); // Run the query. if ($r1) { // If it ran OK. $q2 = "INSERT INTO table2 ... $r2 = @mysqli_query($dbc, $q2); if($r2){...
  18. Saving the file and placing it in the web directory is the same instruction I've used since page 4. There's only the one file.
  19. Sha1() pg414 Ch12: … 3. Save the file and place it in your web directory. … How do you exactly do that, where do you describe this process? Does each logged user have its own file or is it one dedicated for the purpose of security? Thank you
  20. I do get the right results when I enter the query in workbench. I found that when I call login screen and enter “correct values” and execute, it clears the fields and stays at the login screen BUT when I enter “incorrect values" it executes properly and displays errors that those values are incorrect!? After a day of messing with that I finally checked the script and it was from the earlier chapter. It works now. Thanks
  21. The differences between the two queries are pretty obvious but what's really important is: What's the users table definition look like? What error message, if any, is MySQL returning. The answer to the first might inform the second, but you ought to just look at the MySQL error directly. That's assuming there is an error. If there is no error then your query is syntactically fine, there's just no matching rows.
  22. what is the difference between your sql call and my sql call: // $q = "SELECT user_id, first_name FROM users WHERE $userid AND pass=SHA2('$p', 512)"; $q = "SELECT user_id, first_name, username FROM users WHERE username='$uname' AND pass=SHA2('$p', 512)"; $r = @mysqli_query($dbc, $q); // Run the query. // Check the result: if (mysqli_num_rows($r) == 1) { echo 'check_login == 1'; // Fetch the record: $row = mysqli_fetch_array($r, MYSQLI_ASSOC); // Return true and the record: return [true, $row]; } else { // Not a match! // 'The email address and password entered do not match those on file.'; $errors[] = 'The user name and password entered do not match those on file.'; } it does not return anything, it just stays in index.php calling login screen over and over!? It does not enters the "if" statement. Thank you
  23. You shouldn't be storing the user_id in both a cookie and a session. Figure out which approach you ought to be using--cookies or sessions--and just go with that one.
  24. Do I set the cookie first or session? <li><?php // Create a login/logout link: if ( (isset($_COOKIE['user_id'])) && (basename($_SERVER['PHP_SELF']) != 'logout.php') ) { if (isset($_SESSION['user_id'])) { echo '<a href="logout.php">Logout</a>'; } else { echo '<a href="login.php">Login</a>'; } } else { echo '<a href="login.php">Login</a>'; } ?></li> Or do I set the cookie at a later time? Also, there's a session call in login and then in loggedin, both files need to call for session start? I do not believe you say that anywhere in the chapter if both are required. Thanks
  25. Well, I jumped over all the chapters right to the 17th and 18th and combined users table with the other user table, so I had 2 such tables in one DB ... . Now I am back where I should be and already made it to ch11. One has to be very creative to follow thru but I did figure out finally how to work with the pictures. Not easy some of the stuff to follow but it can be done. I think I can skip over the transfers, it's more about shopping card I guess, it's not used for my web idea. Thanks.
  26. In case you need to have both C++/Magick++ and Imagick on your PC (localhost), after much trial and error I found, with thanks to those who posted the guidances and data following, how to install it correctly. My environment is Windows 10 with the latest 64bit XAMPP from: https://www.apachefriends.org/download.html I installed XAMPP/PHP version 7.3.7. My development environment in this case is Visual Studio 2019 and Dreamweaver CS6. The primary guidance is from: https://herbmiller.me/installing-imagick-php-7/ with many thanks to this gentleman. But if you follow this exactly you will not have C++/Magick++ available. Regarding compatible Imagick dlls and ImageMagick versions, see also: https://mlocati.github.io/articles/php-windows-imagick.html with thanks to Michele. But again, the ImageMagick zips will not give you the C++/Magick++ headers or sub-directories. For that you need to do the ImageMagick install from an exe and you can get this from: https://ftp.icm.edu.pl/packages/ImageMagick/binaries/ with many thanks to that institution. You need to select the C and C++ headers option as well as the legacy option during the installation. You need to be extremely careful to install the correct/compatible versions in all cases as advised in Herb Miller's post. By following this guidance exactly I managed to get one installation of ImageMagick with the PHP/Imagick and Magick++ functionality available. Cheers
  1. Load more activity
×
×
  • Create New...