iamconfused Posted October 23, 2016 Share Posted October 23, 2016 "Rewrite the password conditionals found in register.php as a nested pair of conditionals." Why do the password conditionals need to be rewritten to be as a nested pair of conditionals when the un-nested conditionals seemed to be the simpler solution? I'm not even sure if the solution I came up with is the right one. Original un-nested password conditionals: if (empty($_POST['password1'])) { $problem = true; print '<p class="text--error">Please enter a password!</p>'; } if ($_POST['password1'] != $_POST['password2']) { $problem = true; print '<p class="text--error">Your password did not match your confirmed password!</p>'; } Here's what I have: if ( (empty($_POST['password1'])) OR (empty($_POST['password2'])) OR ($_POST['password1'] != $_POST['password2']) ) { #nest password conditionals if ( empty($_POST['password1']) OR (empty($_POST['password2'])) ) { print '<p class="text--error">Please enter a password and/or confirm your password!</p>'; } if ($_POST['password1'] != $_POST['password2']) { print '<p class="text--error">Your password did not match your confirmed password!</p>'; } $problem = true; } Am I on the right track or am I over complicating things? Link to comment Share on other sites More sharing options...
Larry Posted November 13, 2016 Share Posted November 13, 2016 Sorry for the delayed reply! Yes, you are overcomplicating things, but that's okay. As a tip, the conditions can stay the same as they were, but your two if conditionals change. Let me know if you need more information than that! Link to comment Share on other sites More sharing options...
iamconfused Posted November 20, 2016 Author Share Posted November 20, 2016 Thank you for your response! I think I just get really confused when writing IF/IF-ELSE statements. Link to comment Share on other sites More sharing options...
Recommended Posts