/    Sign up×
Community /Pin to ProfileBookmark

Error message positioning

Please help me!

I want to know the code to simply showing the error message beside the textbox in which the error take place. For example: in registration form, when the user input a username that is already exist, i want to show the error message “The username you entered already exist” beside the username textbox
hope you get what i want to point out. Thanks in advance.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ssystemsFeb 10.2012 — Multiple ways to do this. Simplest would be just to spit out the error when postback occurred

[code=php]
<?php
$error = null;
if(isset($_POST['my_post_check'])){
$username = clean_string($_POST['username']);
$query = sprintf("SELECT 1 FROM users WHERE username = '&#37;s'", $username);
//... etc
// If exists
$error = 'Error message';
}
?>

<input name="username" type="text" /><?php !empty($error) ? $error : '' ?>
[/code]
Copy linkTweet thisAlerts:
@mjubana88authorJul 13.2012 — Thanks @ssystems i solved the problem already. More power to you. Cheers!
×

Success!

Help @mjubana88 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...