php在同一页面上获得结果

I Have a php form page where users fill the data and process page to add data to database, Its working fine, But problem is I need the results from process page to be displayed back on to my main page? How to get results back to main page?

In the form's action attribute, set the path to $_SERVER['PHP_SELF'] rather than processing file. This way, form will submit to same page where you can process it.

<form action="<?php echo $_SERVER['PHP_SELF'];?>">
.....
</form>

How about

<form action="mainPage.php" ...>

Simple and your Data will be on the main page.

Use sessions. In script assign a error message to session variable and do redirect. On script.php

$_SESSION['error'] = 'Incorrect email';

index.php

echo $_SESSION['error'];

Don't forget session_start() in begin of scripts.

There's a wide variety of ways, depending on what you're talking about. You'll likely want to use session variables, though. In the processing script:

<?php
start_session();

// Do your processing here

$_SESSION['myvar'] = $finished_data;
?>

And in the main page that called it:

<?php
session_start();

if(!empty($_SESSION['myvar'])) {
     $data = $_SESSION['myvar'];
}

// Use $data here as you need
?>

Looks to me like you need to include some Javascript here, then post the returned data to wherever you want.
there is.. post to same pagewith...
document.getElementById('yourDiv').innerHTML = 'yourReturnedData';
or with $_GET variables.
example...
yoursite.com/yourPage.php?data1=data1&data2=data2
Get returned data by ...

$var1 = $_GET['data1'];
$var2 = $_GET['data2'];

Hope this is of use