Jump to content

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.

Edited by Christian F.

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 :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.