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 7902151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:25:27+00:00 2026-06-03T09:25:27+00:00

I wanted to incorporate GUMP https://github.com/Wixel/GUMP into my site for server side validation. But

  • 0

I wanted to incorporate GUMP https://github.com/Wixel/GUMP into my site for server side validation. But unfortunately the documentation is light and I am new to PHP.

Here is my validation code:

//Validation
$gump = new GUMP(); 
$rules = array(
    'dept'     => 'required|numeric',
    'hosp'     => 'required|numeric',
    'subhosp'  => 'required|numeric',
    'user'     => 'required|numeric',
    'gpo'      => 'required|boolean|exact_len,1',
    'clin'     => 'required|valid_name',
    'clinmail' => 'required|valid_email',
    'comp'     => 'required|alpha_dash',
    'cpt'      => 'required|alpha_dash',
    'past'     => 'required|boolean|exact_len,1',
    'latex'    => 'required|boolean|exact_len,1',   
);
$validated = $gump->validate($_POST,$rules);
print_r($validated); // Something went wrong

The output from the above code gives me an array like so when I am looking at my AJAX response in FireBug:

Array
(
    [0] => Array
        (
            [field] => clin
            [value] => .-0
            [rule] => validate_valid_name
        )

    [1] => Array
        (
            [field] => clinmail
            [value] => %$sd
            [rule] => validate_valid_email
        )

)

And I what I need is something like so:

<div class="error-msg">You did not enter a valid email address</div><br>
<div class="error-msg">You did not enter a valid username</div><br>

From the documentation I get:

    if($validated === TRUE)
{
    // Do something, everything went well
}
else
{   
    // This is where I am stuck. Do I have to loop through and put my <div> tags here?
}

My question is how would the community handle outputting error messages with this class? My only thought is that I loop through the results above and output different messages depending on the field and the rule that was broken but that seems tedious. Is there a better way or a better class to use that does standalone PHP input validation? I was using another very easy to use class but it started breaking when I moved away from inline PHP to AJAX.

  • 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-03T09:25:28+00:00Added an answer on June 3, 2026 at 9:25 am

    edit your code to:

    $gump = new GUMP(); 
    $rules = array(
    'dept'     => 'required|numeric',
    'hosp'     => 'required|numeric',
    'subhosp'  => 'required|numeric',
    'user'     => 'required|numeric',
    'gpo'      => 'required|boolean|exact_len,1',
    'clin'     => 'required|valid_name',
    'clinmail' => 'required|valid_email',
    'comp'     => 'required|alpha_dash',
    'cpt'      => 'required|alpha_dash',
    'past'     => 'required|boolean|exact_len,1',
    'latex'    => 'required|boolean|exact_len,1',   
    );
    
    $error_texts = array(
    'dept'     => 'You must enter a numeric value',
    'hosp'     => 'You must enter a numeric value',
    'subhosp'  => 'You must enter a numeric value',
    'user'     => 'You must enter a numeric value',
    'gpo'      => 'You must enter a boolean value',
    'clin'     => 'You must enter a valid name',
    'clinmail' => 'You must enter a valid email',
    'comp'     => 'You must enter a valid alpha dash',
    'cpt'      => 'You must enter a valid alpha dash',
    'past'     => 'You must enter 1 char',
    'latex'    => 'You must enter 1 char',
    );
    
    $validated = $gump->validate($_POST,$rules);
    
    if($validated === TRUE)
    {
       echo "Every thing is ok";
    }
    else
    {
        foreach($validated as $key=>$error)
        {
            echo '<div class="error-msg">' . $error_texts["{$error['field']}"] . '</div><br />';
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to show the users Name Address (see www.ipchicken.com ), but the only
Wanted to convert <br/> <br/> <br/> <br/> <br/> into <br/>
I wanted to put voice command options into my application. I read stuff online
The first one below works, but, just wanted to see if there's a better
Wanted to merge my branch back into the main trunk today. Haven't worked on
I'm writing a little language into which I will incorporate XML literals in this
This might be a stupid question but I just wanted to make sure... If
I wanted to persist an object( ReportBean ) to the database, but I got
I wanted to update my layout from <?xml version=1.0 encoding=utf-8?> <TextView xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent
I've currently got a project on google code that I'd like to incorporate into

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.