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

  • SEARCH
  • Home
  • 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 6747801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:29:16+00:00 2026-05-26T12:29:16+00:00

I am using PHP to process a form and handle errors. The errors work

  • 0

I am using PHP to process a form and handle errors. The errors work fine, but the issue is that I am wanting to add it to the page with my form on (if an error is found) without refreshing the page. This is because the user can add rows dynamically to my form, and I don’t want these extra rows to be lost (which happens when the page is refreshed).

At the moment then, I simply have the following line on my form (PHP) page:

<?=$errorString?>

And then I define $errorString in booking-engine.php, and add include 'workshops.php'; which refreshes the page to add the error.

Is it possible to add the error without refreshing the page, and if so, how would I go about this?

Thanks,

Nick

FULL PHP SCRIPT:

$row_count = count($_POST['name']);
if ($row_count > 0) {

mysql_select_db($database, $connection);
$name = array();
$workshop = array(); 
$not_found = array();

for($i = 0; $i < $row_count; $i++) {
// variable sanitation...
$name[$i] = mysql_real_escape_string(ucwords($_POST['name'][$i]));
$workshop[$i] = mysql_real_escape_string($_POST['workshop'][$i]);
}
$names = "('".implode("','",$name)."')";

$not_in = Array();

// lets say all names doesn't exist in `conference`
foreach($name as $value) {
    // names in array are keys, not values
    $not_in[$value] = true;
}


$query = mysql_query("SELECT Name FROM conference WHERE Name IN $names"); 
while(list($dbname) = @mysql_fetch_row($query)) {
    // delete those name from $not_in who exists
    unset($not_in[$dbname]);
}

// names in $not_in array are keys, not values
$not_in = array_keys($not_in);

if(empty($not_in)) {
    // its ok, all names have been found. do the magic.
    for($i = 0; $i < $row_count; $i++) {
    $sql = "UPDATE conference SET Workshop = '$workshop[$i]' WHERE Name LIKE '$name[$i]'";
    mysql_query($sql);
    $body .= "Name: " . $name[$i] . "    Workshop: " . $workshop[$i] . "\n\n";
          }

    // send email 
    $success = mail($emailTo, $subject, $body, "From: <$emailFrom>");

    // redirect to success page 
    if ($success){
      print "<meta http-equiv=\"refresh\" content=\"0;URL=thanks-workshop.html\">";
    }
    else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }

}else{
    $errorString = "<div id=\"error\">".'<strong>The following name(s) have not been found on our database of bookings</strong>:<div id=\"names\">'.join(', ',$not_in)."</div><div id=\"error-sub\">Please check the name(s) and try submitting your booking again.  Each name needs to be identical to the name you first booked on to the conference, as described above.</div></div>";
    include 'workshops.php';
}
}
  • 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-05-26T12:29:16+00:00Added an answer on May 26, 2026 at 12:29 pm

    PHP is server-side and what you want to do is on the client. So you’ll need to use (client-side) Javascript to submit the data to your server-side PHP validation and then update the page with the results. See AJAX for background and jQuery.post() for some practical examples.

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

Sidebar

Related Questions

I am using php/ajax to submit a form without page refresh. Here are my
I am using php/ajax to submit a form without page refresh. Here are my
I'm using PHP, and the Kohana framework, but that should be peripheral to this
What is the best way to communicate with another process in PHP? Update: Using
I am creating a process using proc_open in one PHP script. How do i
I have a PHP script where I create a new process using proc_open().It executes
Can I run a PHP CGI script as a background process using exec() ?
Using PHP, I am trying to delete a record, but I want to check
I'm using PHP 5.3's class_alias to help process my Symfony 1.4 (Doctrine) forms. I
I'm using PHP include to include a PHP file that has HTML in it.

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.