Jump to content
Larry Ullman's Book Forums

nootkan

Members
  • Content Count

    29
  • Joined

  • Last visited

Community Reputation

0 Neutral

About nootkan

  • Rank
    Member
  1. Hi Larry, thanks for your reply. I was just using the handle_reg.php code like the pursue task stated. Was I supposed to delete the if else statements and try something different? If so, I am not sure I understand how to figure this out. I have gone back and re-read the previous 6 chapters over a few times and I am still not sure how to figure out how to tell php that I want to just print out the chosen color. My head is spinning so I think I will take a break and see if I can clear my head and try again in a couple of days. Maybe I should continue to work through chapter s
  2. Thanks Necuima, but this is still confusing. I thought that $color_red = 'red'; was defining the variables. I don't understand why I have to define the variables if they're empty. If the color is picked and validated than the color gets printed doesn't it? I am missing something and I can't seem to get my head around it. Will keep trying to try different ways of defining the variables.
  3. Here is the code I tried: // Validate the color: if ($_POST['color'] == 'red') { $color_red = 'red'; } elseif ($_POST['color'] == 'yellow') { $color_yellow = 'yellow'; } elseif ($_POST['color'] == 'green') { $color_green = 'green'; } elseif ($_POST['color'] == 'blue') { $color_blue = 'blue'; } else { // Problem! print '<p class="error">Please select your favorite color.</p>'; $okay = FALSE; } // If there were no errors, print a success message: if ($okay) { print '<p>You have been successfully registered (but not really).</p>'; print "<p>You will turn
  4. Sorry Larry, I knew the code was working just cannot understand how the foreach line is working when the $title and $chapters variables aren't assigned to anything. Looks to me like the variables $phpvqs, $phpadv and $phpmysql were assigned to the chapters and titles. So I am having trouble understanding what makes the foreach work.
  5. Thanks Necuima, I did try that also with no success. I think I mentioned in my first post. I'll keep digging.
  6. One of the pursue tasks asked to do is: "rewrite one of the versions handle_reg.php so that it prints the users favorite color selection in the users favorite color. The hint says to use css and concatenation. I've tried a few things but can't seem to understand how to figure out the logic for this task. Below is one of the methods I tried that didn't work and I tried to debug for hours with no success. I also tried slashing the double quotation marks in the print command and add the paragraph tag to each style with no success. Please advise as to what I am not understanding.
  7. Okay so I 've created the books.php script like your book says and everything looks fine when viewing in my browser. I decided to try the "access every element of every array" tip to see if it worked even though I am not understanding how the Title and Chapters are found when they haven't been declared. What am I not understanding? <!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=
  8. 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; }
  9. 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.
  10. 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</titl
  11. Wow, okay I'll remove it from my server until I understand a little more about security as I don't quite understand everything both of you are trying to tell me. I'm guessing once I get through the book I'll have a better understanding and know what variables to use. Thanks for your replies.
  12. On page 100 it states that three functions can be used to beef up security in a php script. htmlspecialchars(), htmlentities() and strip_tags(). My question is: Should I be using strip_tags() in all my scripts to prevent cxs attacks? For example, as part of the pursue task in chapter 4, I created a simple form weight calculation script that I used on one of my websites to determine the weight of a fish based on the length x girth / 775. Although the text box sizes in the form are only "5" can someone still do a cxs attack using the simple form? Here is what I placed inside my php proce
  13. Is there a reason for placing spaces between some of the two variables when doing a calculation using numbers and not others? For example in the book it shows: $taxrate = $tax/100; $taxrate = $taxrate + 1; $total = $total * $taxrate; I've tried it both ways and it works fine. Just wanted to be sure that there isn't something I missed that will be needed further down the road. Don't want to develop bad habits now. Also I've read that spaces add up the loading time and should be avoided. Is this true?
  14. Oh I see so it's not actually a variable value unless it is in brackets and variables can be used by themselves without quotes unless the output requires them. Thanks for your help.
  15. I thought all variables had to have either single or double quotes. I must be not understanding something. I'll go back and read again.
×
×
  • Create New...