Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9233313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:31:27+00:00 2026-06-18T06:31:27+00:00

Hi I need some help please, if its possible. I have created a PHP

  • 0

Hi I need some help please, if its possible.

I have created a PHP function that shows the errors of a form server-side validation right below each field. Here are the basic parts:

$errors = array();

//check if e-mail is valid
    if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){
        $errors['email'] = "Please give a valid email.";
    }
.....

function display_error($field_name){
    global $errors;
    if($errors[$field_name]){
        echo "<span class=\"form_error\">" . $errors[$field_name] . "</span>\n";
    }
}

....

<span id="spryEmail">
<label>E-mail *<br />
<input type="text" name="email" id="email" />
</label>
<span class="textfieldRequiredMsg">Your e-mail is required.</span><span class="textfieldInvalidFormatMsg">Please provide a valid e-mail.</span></span>
<?php display_error('email'); ?>

When I preview the form on the browser (I temporarly disable javascript), it shows me this:

Notice: Undefined index: email in C:…….\functions.php on line 60
, which points to the if statement inside the function. How can I fix this Notice, so that doesn’t show up?
Note: If I submit the form, the error message show up correctly.

2) AS you notice I’ve also added some Spry validation that validates onblur. I have a captcha field

<span id="spryCaptcha">
<label>Security code *<br />
<img src="captcha.php" id="imgCode" />
<input type="text" name="captcha" id="captcha" />
</label>
<span class="textfieldRequiredMsg">Please type the code you see.</span></span>
<?php error_for('captcha'); ?>

and what I’d like to make is if the user enters the wrong code the message from the error_for function also to display onblur, before hitting the submit button. How can I make this work?

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:31:28+00:00Added an answer on June 18, 2026 at 6:31 am

    Actually this change in the code inside the function if(!empty($errors[$field_name])){ ... } worked pretty good on my 1st question!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help to get this right, please. I have created an iPad
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
I need some help with a LINQ query in VB.Net, please. I have this
I need some help with priviligies in centos I have a file in home/admin/public_html/generate.php
I need some help! Please. I am trying to develop a very very simple
I need some with help with PowerShell, please. It should be pretty easy: I
please i need you help with my script.. I'm trying to echo some content
Need some help... I have jasperserver 4.1 installed on my ubuntu. It runs via
Need some help to solve this. I have a gridview and inside the gridview
I need some help please. I need to create a drop down list and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.