close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Record Insert Success or Unsuccessful message

Thread began 2/13/2021 12:16 pm by Michael | Last modified 8/12/2021 3:57 pm by Ray Borduin | 956 views | 9 replies |

Michael

Record Insert Success or Unsuccessful message

Please how can I add a success message that reads thus "Record Inserted Successfully" whenever my records are inserted into the database or "Record insert was not Successfully"

Here is my code

<?php
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$InsertQuery = new WA_MySQLi_Query($SFT);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "findings";
$InsertQuery->bindColumn("indg_id", "i", "".((isset($_POST["indg_id"]))?$_POST["indg_id"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("ind_id", "i", "".((isset($_POST["ind_id"]))?$_POST["ind_id"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("question", "s", "".((isset($_POST["question"]))?$_POST["question"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("findings", "s", "".((isset($_POST["findings"]))?$_POST["findings"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("conclusion", "s", "".((isset($_POST["conclusion"]))?$_POST["conclusion"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("recomdns", "s", "".((isset($_POST["recomdns"]))?$_POST["recomdns"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("addedby", "s", "".((isset($_POST["addedby"]))?$_POST["addedby"]:"") ."", "WA_DEFAULT");
$InsertQuery->saveInSession("fin_id");
$InsertQuery->execute();
$InsertGoTo = "dlis";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>

Thank you

Sign in to reply to this post

Ray BorduinWebAssist

Add a url parameter to your success redirect and then show the success message when the url parameter exists like:

php:
<?php

if (isset($_GET["success"])) {
?>
Success Message Here
<?php
}
?>
Sign in to reply to this post
Did this help? Tips are appreciated...

Michael

Record Insert Success or Unsuccessful message

Originally Said By: Ray Borduin
  Add a url parameter to your success redirect and then show the success message when the url parameter exists like:
php:
<?php

if (isset($_GET["success"])) {
?>
Success Message Here
<?php
}
?>
  



Thank you so much but I am not sure I know how to add a url parameter to my success redirect. Please help me with the full code including the URL Parameter you mentioned.

Thank you

Sign in to reply to this post

Ray BorduinWebAssist

$InsertGoTo = "yoursuccesspage.php?success";

Sign in to reply to this post
Did this help? Tips are appreciated...

Michael

Record Insert Success or Unsuccessful message

Originally Said By: Ray Borduin
  $InsertGoTo = "yoursuccesspage.php?success";  



Thank you so so much.

Now putting all together I should get this right

<?php
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$InsertQuery = new WA_MySQLi_Query($SFT);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "findings";
$InsertQuery->bindColumn("indg_id", "i", "".((isset($_POST["indg_id"]))?$_POST["indg_id"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("ind_id", "i", "".((isset($_POST["ind_id"]))?$_POST["ind_id"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("question", "s", "".((isset($_POST["question"]))?$_POST["question"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("findings", "s", "".((isset($_POST["findings"]))?$_POST["findings"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("conclusion", "s", "".((isset($_POST["conclusion"]))?$_POST["conclusion"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("recomdns", "s", "".((isset($_POST["recomdns"]))?$_POST["recomdns"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("addedby", "s", "".((isset($_POST["addedby"]))?$_POST["addedby"]:"") ."", "WA_DEFAULT");
$InsertQuery->saveInSession("fin_id");
$InsertQuery->execute();
$InsertGoTo = "dli?success";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>

<?php
if (isset($_GET["success"])) {
?>
Success Message Here
<?php
}
?>

Sign in to reply to this post

Ray BorduinWebAssist

Yes, that should work.

Sign in to reply to this post
Did this help? Tips are appreciated...

Michael

Originally Said By: Ray Borduin
  Yes, that should work.  




Hello Sir, this success message is not popping up as expected. It just shows at the top.

Please see image at the bottom. I used the code as it.

<?php
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$InsertQuery = new WA_MySQLi_Query($SFT);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "findings";
$InsertQuery->bindColumn("indg_id", "i", "".((isset($_POST["indg_id"]))?$_POST["indg_id"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("ind_id", "i", "".((isset($_POST["ind_id"]))?$_POST["ind_id"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("question", "s", "".((isset($_POST["question"]))?$_POST["question"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("findings", "s", "".((isset($_POST["findings"]))?$_POST["findings"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("conclusion", "s", "".((isset($_POST["conclusion"]))?$_POST["conclusion"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("recomdns", "s", "".((isset($_POST["recomdns"]))?$_POST["recomdns"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("addedby", "s", "".((isset($_POST["addedby"]))?$_POST["addedby"]:"") ."", "WA_DEFAULT");
$InsertQuery->saveInSession("fin_id");
$InsertQuery->execute();
$InsertGoTo = "dli?success";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>

<?php
if (isset($_GET["success"])) {
?>
Your application was successfully submitted
<?php
}
?>

Please kindly review and advice.

Thank you so much

Sign in to reply to this post

Ray BorduinWebAssist

You can move that code to wherever you want it to appear. It appears on the top of the page because that is where it was placed.

Sign in to reply to this post
Did this help? Tips are appreciated...

Michael

Originally Said By: Ray Borduin
  You can move that code to wherever you want it to appear. It appears on the top of the page because that is where it was placed.  



OK that is a good one.

Lastly please, is it possible to make it to popup using JS Script alert code??? I want it to popup like a modal.

Is it also possible to add some CSS to it to make it look well formatted???

Thank you

Sign in to reply to this post

Ray BorduinWebAssist

Yes. Create a modal or style it before adding the conditional code to only show when the insert is successful. You can make it look however you want. It is just HTML like anything else on the page.

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...