0
How to ensure the username required,email required,password required and passwords do not match is working well
I am trying to develop a registration form with the following code <form method="post" action="register.php"> <?php include('errors.php'); ?> <div class="input-group"> <label>Username</label> <input type="text" name="username" value="<?php echo $username; ?>"> </div> <div class="input-group"> <label>Email</label> <input type="email" name="email" value="<?php echo $email; ?>"> </div> but the function is not working in my register form.When I enter username and click register it doesn't show password required and email required but rather has all the three including username required .Kindly help!
7 ответов
+ 1
evans just simply add "required" to the input opening tag.
Ex: <input type="text" required />
+ 1
What's going on within register.php and errors.php?
It's hard to tell what the problem is without knowing what those files do, or why you include errors.php.
+ 1
https://uploads.disquscdn.com/images/d20aecbe63e7f9c682e23e45ae01a17a5890a037801f39ef39074c1dbba53944.png?w=800&h=453 clink on that to view my form. The required fields at the top there in a functional form, when you type in user and click on register, password required and email required should be left at the required fields at the top there. Also when you type the email only and click register, the username required and password required fields are visible at the top there and so on. Also when all fields are entered nothing really happens. Instead the details entered vanish away and no connection even with the database.Kindly help
+ 1
Alright, now we're talking. This way I can understand your intention better. Thanks for collaborating 👍
I would first suggest you to follow Thống Nguyễn advice to set 'required' attribute for the input boxes. It will lessen the work you'd have to do.
Secondly, I would also suggest you to use front-end validation using Javascript first, before sending the form data over for PHP to work with. This is better because you wouldn't need to transfer any data before data is validated, also faster, because data doesn't need to travel back and forth through the network (no traffic delays).
Please search the net further for Javascript powered form validation tool that is suitable for your needs.
+ 1
Thanks a lot, I'll tell you the feedback once I search the tool.
0
Good luck, keep me posted 👌
0
ok