Python Forum
Show powershell errors in flask-wtf web form
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Show powershell errors in flask-wtf web form
#5
Quote:but what about outputting the error on the html form instead of just the console as end users wont see the console they will just have access to the html form

In PHP there is a kind of global array known as $_SESSION with elements like: $_SESSION["any name here"].

Once you start $_SESSION, you can store anything in it, like:

Quote:$_SESSION['isloggedin'] = 'False';
$_SESSION['email_error'] = "This email {$email} is not in the database."
$_SESSION['PWerror'] = '密码不一样 Passwords did not match';
$_SESSION['PWsuccess'] = '改变密码成功了!Password changed for User with email: ' . $email . '!';

The users clicks send and the PHP to evaluate the contents of the form takes over. If an error occurs, the user is bounced back to the form, where the error can be displayed as $_SESSION['any name here'] in a div and the $_SESSION error is unset, ready for the next attempt when the user clicks the send button again:

Quote:<div id="div-blue">
If something is wrong, you will see an error message here. <br>
<?php
if(isset($_SESSION['PWerror'])){
echo "An error occurred: " . $_SESSION['PWerror'] . '<br>';
unset($_SESSION['PWerror']);
}

if(isset($_SESSION['PWsuccess'])){
echo "Result: " . $_SESSION['PWsuccess'] . '<br>';
unset($_SESSION['PWsuccess']);
}
?>
</div><br>

Maybe Flask has something like $_SESSION?
Reply


Messages In This Thread
RE: Show powershell errors in flask-wtf web form - by Pedroski55 - Jun-28-2024, 01:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Beta6 of my password flask-wtf web form robertkwild 3 179 Jul-02-2024, 10:30 AM
Last Post: robertkwild
  Cant get powershell script to run with subprocess robertkwild 2 181 Jun-27-2024, 01:23 PM
Last Post: robertkwild
  Running powershell command in flask wtf form robertkwild 10 411 Jun-27-2024, 09:49 AM
Last Post: robertkwild
  Passing web form to powershell robertkwild 1 289 Jun-14-2024, 10:16 AM
Last Post: Akshiya
  using split in my flask wtf form robertkwild 1 206 Jun-11-2024, 05:19 PM
Last Post: deanhystad
  making a form purely with flask-wtf robertkwild 15 897 Jun-01-2024, 11:53 AM
Last Post: robertkwild
  using PowerShell from Python script for mounting shares tester_V 8 885 Mar-12-2024, 06:26 PM
Last Post: tester_V
  PowerShell & Python deep_logic 2 856 Jun-06-2023, 06:34 AM
Last Post: buran
  PIL Image im.show() no show! Pedroski55 2 1,102 Sep-12-2022, 10:19 PM
Last Post: Pedroski55
  How to write a part of powershell command as a variable? ilknurg 2 1,245 Jul-26-2022, 11:31 AM
Last Post: ilknurg

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020