Right on both counts.Pavilion wrote:Code: Select all
<label for="password">Password</label> // this line sets up the label <input type = "password" name="password" /> // this line sets up the input control and gives it a "password" type.
The syntax used above is functionally equivalent to if { }.Pavilion wrote:Code: Select all
<?php if (isset($errors['password'])): ?> // Other than starting an "if" statement, I have no idea what this line is doing. If I had to guess... I'd say it was "grabbing" any error for later reference.
At the beginning of the script, we checked if $_SESSION['errors'] existed. That is to say, we checked if register_post2.php directed us back here with error messages. If it did, we assign it to the local $errors variable (technically an unnecessary step, but it saved me from rewriting code). On any given page load, we may or may not have been redirected from register_post2.php; if we're not redirected, then clearly there aren't any error messages. That said, what we're doing here is checking if any errors have been returned to this page and displaying them if they have. We're storing the errors in an array so each error can be displayed next to the relevant field.
This was mostly explained above. If an error was sent back from register_post2.php, we display it here. Why it's not displaying an error about a blank password I cannot say without seeing your new code for register_post2.php. Finally, I used a span tag because it's an inline element and could thus be displayed next to the input element.Pavilion wrote:Code: Select all
<span class="error"><?php echo $errors['password'];?></span> // I have no idea what this line is doing. It seems to be setting up an echo, but when I leave the password field blank - the only error message I receive is the one set up in register_post2.php. In addition to not understanding the reason for an "echo" - I also don't understand why the <span> tag is necessary - what is it doing?