Jump to content

Submit Form - Error/success Message On Index File


hahaitwork

Recommended Posts

Like the title says: Submit Form - Error/Success message on Index file

At the "insertken.php" I got this script:

This is the end by the way..

Anyhow, I would like to have this Error or Successful message on my index file ( form.php )

Any idea how I can make that happen ?

The thing is that I would really like my website not to go to the other page, but rather update on the same site, like.. ajax etc.

But it also needs to remove everything in the form, and show a success/error message at the buttom.

 

Maybe this wasn't a good way to explain but, yeah? :) ask if you wounder about anything. Could send a picture if needed.

 

 

$sql="INSERT INTO $tbl_name(id, name, description, price, sla, quantity, fix)VALUES('$id', '$name', '$description', '$price', '$sla', '$quantity', '$fix')";
$result=mysql_query($sql);


if($result){
echo "Successful";
echo "<BR>";
echo "<a href='form.php'>Back to main page</a>";
}

else {
echo "ERROR";
}
?>

Since I recently posted this in another thread, to give an example of a solution to pretty much the same issue: My contact form processing code.

 

The $Template->_FORM_FIELD_{name} properties are being used by the template engine to pre-populate the form with already posted data, and $Template->_MESSAGE to add a message above the form. The template engine also uses the $Page variable to display the actual form, and since it's never overwritten in the script it'll always show the form after the code has been parsed.

 

However, if you don't want the page to reload (even with pre-populating the fields), then you will need to use AJAX.

Since I recently posted this in another thread, to give an example of a solution to pretty much the same issue: My contact form processing code.

 

The $Template->_FORM_FIELD_{name} properties are being used by the template engine to pre-populate the form with already posted data, and $Template->_MESSAGE to add a message above the form. The template engine also uses the $Page variable to display the actual form, and since it's never overwritten in the script it'll always show the form after the code has been parsed.

 

However, if you don't want the page to reload (even with pre-populating the fields), then you will need to use AJAX.

 

Thanks, will take a look when I got the time :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.