Jump to content
Larry Ullman's Book Forums

All Activity

This stream auto-updates     

  1. Yesterday
  2. Last week
  3. Yeah, that can be pretty common. Kudos for figuring it out and thanks for letting us know you did!
  4. This is a little confusing for me. Are you saying that I should be using the following when validating the passwords for example? // Validate the password: if isset((empty($_POST['password']))) { print '<p class="error">Please enter your password.</p>'; $okay = FALSE; } // Check the two passwords for equality: if isset(($_POST['password'] != $_POST['confirm'])) { print '<p class="error">Your confirmed password does not match the original password.</p>'; $okay = FALSE; }
  5. Okay I was able to figure out what I did wrong. It seems that somehow I managed to call the scripts in the browers with c:/ instead of http://localhost. Not sure when or how that happened as I usually just reopen the browser from my last session. In any case, I'm good to go on.
  6. After a long absense, I've decided to try to once again get my head around php. I have made to chapter 6 but seem to have an issue that I cannot debug. Was wondering if someone could have a look at my code to see what I am missing or doing wrong? register.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTDxhtml1-transitional.dtd"><html xmlns="http:///www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv-"content-type" content="text/html; charset=utf-8"/> <title>Registration Form</title> </head> <body> <!-- register.html --> <div><p style="font-size:20px"><strong>Please fill out this form to register:</strong></p> <form action="handle_reg.php" method="post"> <p>Email Address: <input type="text" name="email" size="30" /></p> <p>Password: <input type="password" name="password" size="20" /></p> <p>Confirm Password: <input type="password" name="confirm" size="20" /></p> <p>Year You Were Born: <input type="text" name="year" value="YYYY" size="4" /></p> <p>Favorite Color: <select name="color"><option value="">Pick One</option><option value="red">Red</option><option value="yellow">Yellow</option> <option value="green">Green</option><option value="blue">Blue</option></select></p> <p><input type="checkbox" name="terms" value="yes" /> I agree to the terms (whatever they may be).</p> <input type="submit" name="submit" value="Register" /> </form> </div> </body> </html> handle_reg.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Registration</title> </head> <body> <h1>Registration Results</h1> <?php // Script 6.2 - handle_reg.php /* This script receives seven values from register.html: email, password, confirm, year, terms, color, submit */ // Address error management, if you want. // Flag variable to track success: $okay = TRUE; // If there were no errors, print a success message: if ($okay) { print '<p>You have been successfully registered (but not really).</p>'; } ?> </body> </html> Here is what I see when filling out the form: I am using wamp with apache 2.4.33, php 7.2.4 and mysql 5.7.21
  7. That's a really good technique, Jay! Thanks for sharing that!
  8. Ok. Thank you Jay. I will try and implement your instructions. Really appreciate you taking time out to reply. regards
  9. dmx1, You are building the complete list item as you iterate through the loop. Do this... open a notepad. Manually look/loop through the code. 1. When you get to echo, take that part and put it in the notepad. 2. After it is in the note pad replace any variable names with their corresponding values. $k is symbolic for the "Key" part of the Key-Value pair. $v is the symbolic for the "Value" part of the Key-Value pair. In case you missed it the Key / Values are on page 67. step 4. 3. if you did this correctly, you will end up with the same thing as figure 3.9 on page 68. Your web server will do exactly as you did (if you did it correctly) and build a "li" or List Item for each time through the loop. The "active" class part is to apply special CSS "Class" to the element so it will display differently. 4. If this helps you please drop a line at jay.a.carlson@gmail.com /r Jay Please checkout my slightly modifed website at https://J5CMarketing.com
  10. Hi Larry, I tried researching but I still don't fully understand the following lines of code on page 68 in the 2nd edition of Effortless Ecommerce: /// Create each menu item: foreach 1. foreach ($pages as $k => $v) { // Start the item: 2. echo ' <li ' ; //Add the class if it's the current page: 3. if ($this_page == $v) 4. echo ' class="active" ' ; // Complete the item: 5. echo ' ><a href= " ' . $v . ' "> ' $k . ' </a></li> ' ; // End of FOREACH loop. I understand that the foreach loop iterates through each page's key and value' I get confused at line 2: echo ' <li ' ; This displays the list item. Qu 1: The list item isn't completed, it's just an 'li' tag, so how do you print just a 'li' tag? Line 3 and 4 confuses me. if ($this_page == $v) echo ' class="active" ' ; You say if the current page is equal to it's value, then print the class with a value of 'active' Qu: 2 How do you print a class with a value of active? Can you explain how the echo statement prints a class with a value of active I looked inside the css stylesheet and there's no 'active' selector, so how does class='active' relate to the page's values? Line 5 prints the hyperlink. It prints the value and the associated key echo ' ><a href= " ' . $v . ' "> ' $k . ' </a></li> ' ; I don't understand how you constructed it in this way. Qu 3: What's the significance of the following snippet below, and why add in '>' . $v . ' "> ' $k . ' Thanks regards
  11. Earlier
  12. Also, why do you need to call the config.inc.php file in every page?
  13. Hi Larry, I'm a newbie so please forgive the basic questions On page 60, you wrote the code: if(!defined('LIVE')) DEFINE('LIVE', false); You said if you wanted to allow the live setting to be set on a single page, in order to debug that page, you would write: DEFINE('LIVE', true); require('./includes/config.inc.php'); I don't really understand this logic. If you wanted to debug a specific page, you would write on the specific page, DEFINE('LIVE', true); require('./includes/config.inc.php'); So 'LIVE' would be set to true, then the config.inc.php file would be called, but my confusion is: QU 1: After the config.inc.php is called, how would that debug the specific page in question ie, how would that then link back to the specific page you wanted to debug? Qu 2: In the above scenario, is the website initially offline, ie localhost, because 'LIVE' is set to false, and you have then changed 'LIVE' to true, in one page, in order to see how it operates in a live environment? Qu 3: Can you explain the process of setting 'LIVE' to true on one specific page ie, the config.inc.php file is called and............ Thank you. regards
  14. Hi Larry, Thank you for all the books you have written. I hope you and your family are safe and health. A quick question for you. I love the "PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide 5th Edition" book. I am wondering are you planning to publish a new edition in the near future? Do you have a road map on that? Thanks again. Jim.
  15. Thanks for catching that and for letting me know! I'll pass it along to the publisher.
  16. Hi, Just noticed the following code error for the password_hash() function used on page 626, line 34. The code base shown in the book only passes 1 parameter, // Incorrect number of parameters $ph = password_hash($p); This function requires 2 parameters as outlined in the PHP docks here: https://www.php.net/manual/en/function.password-hash.php This should probably be: (unless you wish to us a differnet constant based on your own project needs) $ph = password_hash($p, PASSWORD_DEFAULT); Hope this will help someone learning that may have gotten stuck on this project.
  17. You need to execute the query from within the FOREACH as that's the only place you have access to each individual selected size.
  18. okay thanks but I am trying to use foreach loop where I want to enter the $_Post['size'] into database but don't know how to assign the $i variable below back to the $size variable if(isset($_POST[‘submit’])){ $size = $_POST[‘size’]; foreach ($size as $i) { echo ("$i<br>"); } $insert_product = "insert into products (size) values (’$size’)
  19. it's in the sql.sql file: https://github.com/LarryUllman/phpmysqlvqp-5ed/blob/master/sql.sql
  20. Ah, no, you can't do that. You'll need to use PHP to break the multiple selections into their single counterparts and insert each one separately.
  21. Thanks very much sir, I still need your help. How do I allow size_id column in product table to store more than one size_id on a single record? I tried it directly in phpmyadmin to insert more than one size_id on the size_id column but it was given error
  22. I can't find the script that quickly populates the users table on chapter 5. There's only a readme.txt on git.
  23. Add the "multiple" property to the opening select tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select
  24. Please, I want to convert this single select option to multiple choice select options. i,e to select more than one option in the select dropdown <?php $get_sizes = "select * from sizes"; $run_sizes = mysqli_query($con,$get_sizes); while ($row_sizes=mysqli_fetch_array($run_sizes)){ $size_id = $row_sizes['size_id']; $size_name = $row_sizes['size']; echo " <option value='$size_id'> $size_name </option> "; } ?> </select><!-- form-control Finish -->
  25. I haven't used PHPStorm in a long while, so I'm not positive but maybe adding id="gender" to both of the inputs would solve it.
  1. Load more activity
×
×
  • Create New...