Custom Error Messages - Post ID 257642

User 2778508 Photo


Registered User
31 posts

How do I make the form display a custom error message after it has been submitted?

Here's an example use case: a login form should have a custom error saying that the username or password were invalid.

My form is using redirect confirmation and it's during the execution of the redirected .php file that I detect an error. I'm thinking I need to use a header("Location: [url]") call to render the form with a custom error message but I'm open to any technique that will send the user back to the form and display an error message.

Curtis
User 187934 Photo


Senior Advisor
20,271 posts

Hi Curtis,
Click on the element you want to work with.
Click on the properties tab.
Scroll down to the bottom and enter your Error Message in the box provided.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2778508 Photo


Registered User
31 posts

Eric,

Two things about your solution:

1) The error message always appears after the cursor leaves the field. It should only appear when the username or password are incorrect.
2) The username/password check is in the redirected confirmation page (after doing a database lookup, of course). How do I trigger the error message to display from that PHP script?

Thanks.

Curits
User 187934 Photo


Senior Advisor
20,271 posts

1. Make both elements not required.
2. If you have your server setup to parse php inside html you can do this.
<?php
session_start();
$username_error = $_SESSION['username_error'];
?>
<input name="username" id="item4_text_1" type="text" maxlength="254" placeholder=""
autocomplete="off" data-hint="" />
<?php if(isset($username_error)){ echo '<div id="error">That name doesn't exist!</div>';unset($_SESSION['username_error']);}?>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.