Jump to content
Larry Ullman's Book Forums

paulja2014

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About paulja2014

  • Rank
    Newbie
  1. Hello, I've been working this script and up until this section everything has been fine. Not sure what is causing this error - I ran it through a couple different debuggers and they do not report errors. My IDE (Coda 2) does say their is a parsing error on line 2, but I don't see it. Anything? Love the book. Way easier to use than anything else I've tried. ===== <!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> <style type="text/css" media="screen"> .error { color: red; } </style> </head> <body> <h1>Registration Results</h1> <?php // Script 6.6 - handle_reg.php #5 /* 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; // Validate the email address: if (empty($_POST['email'])) { print '<p class="error">Please enter your email address.</p>'; $okay = FALSE; } // Validate the password: if (empty($_POST['password'])) { print '<p class="error">Please enter your password.</p>'; $okay = FALSE; } // Check the two passwords for equality: if ($_POST['password'] != $_POST['confirm']) { print '<p class="error">Your confirmed password does not match the original password.</p>'; $okay = FALSE; } // Validate the year: if ( is_numeric($_POST['year']) AND (strlen($_POST['year']) == 4) ) { // Check that they were born before 2011. if ($_POST['year'] < 2011) { $age = 2011 - $_POST['year']; // Calculate age this year. } else { print '<p class="error">Either you entered your birth year wrong or you come from the future!</p>'; $okay = FALSE; } // End of 2nd conditional. } else { // Else for 1st conditional. print '<p class="error">Please enter the year you were born as four digits.</p>'; $okay = FALSE; } // End of 1st conditional. // Validate the terms: if ( !isset($_POST['terms'])) { print '<p class="error">You must accept the terms.</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 $age this year.</p>"; } ?> </body> </html>
×
×
  • Create New...