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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:06:47+00:00 2026-06-08T17:06:47+00:00

I got an ajax submitting form source code, and learning it right, I found

  • 0

I got an ajax submitting form source code, and learning it right, I found the return errors are all in a big square. I want to separate errors to where they belong to.
then I can simply add something like following code

 <?php if($_session('errorarray'): ?>
   <span class="errorclass"><?php echo $errorarray['phone']; ?></span>
 <?php endif; ?>

here is validation php code, (I have 5 items need to be checked)

 $error = array();

    if(!check('name'))
        $error[]='too short!';
    else if(validate_name($_POST['name']))
        $error[]='letters please!'; 

    ..........


if(checkphone($_POST['phone'])){
    $error[]="Please enter a valid phone number";
}   

here is the code return to $_Session

if(count($error))
{
    if($_POST['ajax'])
    {
        echo '-1';
    }

    else if($_SERVER['HTTP_REFERER'])
    {
        **$_SESSION['errorarray'] = array ($error);** // possible? 
        $_SESSION['post']=$_POST;

        header('Location: '.$_SERVER['HTTP_REFERER']);
    }

    exit;
}

Sorry I am very new to php. Hope my expression is not too hard to understand.
Many thanks in advance.

  • 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-08T17:06:48+00:00Added an answer on June 8, 2026 at 5:06 pm

    You can just set $_SESSION['errorarray'] = $error; Then in your view, you can do something like <span class="errorclass"><?php foreach ($_SESSION['errorarray'] as $err) { echo $err; } ?></span>

    Sorry, your question is a bit unclear, if you provide more details we could probably give you a better answer.

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

Sidebar

Related Questions

Got a working AJAX form: @using (Ajax.BeginForm(...)) I want to disable the button while
I got some trouble submitting a form with ajax. Since HTML5 Form already have
I started out with this code for submitting a form using the jQuery ajax
I've got an ajax form in an MVC 2 application. I cannot find the
I've got an Ajax call for log in here is the code: //if MOUSE
So I've got an Ajax-based webapp. The homepage serves most - almost all -
I've got a problem with submitting AJAX forms - using this tutorial . My
I've got some Ajax code with calls a WebMethod from within my back-end code
I've got a PHP/AJAX form on my site at http://www.brianrhea.com (click Request Project) When
Hi I have got an ajax code as follows: $.ajax({ type:POST, url: 'sample.php', data:data=+data,

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.