addRule('name', 'Name is required', 'required'); $form->addRule('email', 'Email is required', 'required'); $form->addRule('password', 'Password is required', 'required'); // Set validation rules for email and password fields $form->addRule('email', 'Invalid email format', 'email'); $form->addRule('password', 'Password must be at least 8 characters long', 'minlength', 8); // Check if the form is valid if ($form->isValid($_POST)) { // If the form is valid, register the user // ... } else { // If the form is invalid, display an error message echo 'The following errors occurred:
'; echo '
createFormBuilder() ->add('name', TextType::class, ['required' => true]) ->add('email', EmailType::class, ['required' => true]) ->add('password', PasswordType::class, ['required' => true]) ->add('submit', SubmitType::class) ->getForm(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $form->handleRequest($_POST); if ($form->isSubmitted() && $form->isValid()) { // If the form is valid, register the user // ... } else { // If the form is invalid, display an error message $errors = $form->getErrors(true, false); echo 'The following errors occurred:
'; echo '