jimfog Posted October 25, 2016 Share Posted October 25, 2016 I am facing a problem with the markup of a registration form. The user is presented with some links and each of them when clicked leads to a registration form-so far everything is OK. But when the submit button is clicked(and if errors are found) the user is taken to the registration form again-but this time the markup is different,the errors displayed. In other words I have markup in my HTML file for two different registration forms(I mean the form is the same of course but the one appears when the link is clicked and the other when the submit button clicked.) Take a look here http://hastebin.com/iriqiyepom.xml : It is a mess...there are times that in the screen the same form appears twice. How I could clean it up? The reason that lead me using 2 forms is that the second contains markup for errors shown(span elements). Link to comment Share on other sites More sharing options...
dsonesuk Posted October 25, 2016 Share Posted October 25, 2016 Surely during validation, you can control when and where the error markup will show, so you do not require two forms. Link to comment Share on other sites More sharing options...
Ingolme Posted October 25, 2016 Share Posted October 25, 2016 Just put your error messages within the same form and only display them if there is a message to display: <label for="first-name-input">First Name</label> <input type="text" name="first-name" id="first-name-input"> <?php if(isset($errors['first-name'])) { /* Only show an error message if there was an error */ ?> <span class="error"><?php echo $errors['first-name']; ?></span> <?php } ?> Link to comment Share on other sites More sharing options...
jimfog Posted October 26, 2016 Author Share Posted October 26, 2016 What I cannot understand is how to use conditionals to achieve this. Here the form must appear when the link is clicked which is an if(isset['GET']) { //form } Yes but we also must take into consideration when the submit button is clicked: if (isset($_POST['submit'])) { //form } So my problem now is how to combine these two...and as you said having one form. Link to comment Share on other sites More sharing options...
dsonesuk Posted October 26, 2016 Share Posted October 26, 2016 <?php if(isset($_GET['btype') || isset($_POST['submit'])) { ?> <!-- show form --> <?php } ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now