#importing CGI library
import cgi
# Set up HTML header
print("Content-Type: text/html")
print() # Blank line separating headers from the body
# Get form data
form = cgi.FieldStorage()
username = form.getvalue('username')
password = form.getvalue('password')
# Sample username and password for validation
valid_username = "user123"
valid_password = "pass123"
# Begin HTML output
print("<html>")
print("<head>")
print("<title>Login Result</title>")
print("</head>")
print("<body>")
#
if username and password:
if username == valid_username and password == valid_password:
print(f"<h2>Welcome, {username}!</h2>")
print("<p>Login successful.</p>")
else:
print("<h2>Login Failed!</h2>")
print("<p>Incorrect username or password.</p>")
else:
print("<h2>Error!</h2>")
print("<p>Please enter both username and password.</p>")
print("</body>")
print("</html>")
I2ltcG9ydGluZyBDR0kgbGlicmFyeSAKaW1wb3J0IGNnaQoKIyBTZXQgdXAgSFRNTCBoZWFkZXIKcHJpbnQoIkNvbnRlbnQtVHlwZTogdGV4dC9odG1sIikKcHJpbnQoKSAgIyBCbGFuayBsaW5lIHNlcGFyYXRpbmcgaGVhZGVycyBmcm9tIHRoZSBib2R5CgojIEdldCBmb3JtIGRhdGEKZm9ybSA9IGNnaS5GaWVsZFN0b3JhZ2UoKQp1c2VybmFtZSA9IGZvcm0uZ2V0dmFsdWUoJ3VzZXJuYW1lJykKcGFzc3dvcmQgPSBmb3JtLmdldHZhbHVlKCdwYXNzd29yZCcpCgojIFNhbXBsZSB1c2VybmFtZSBhbmQgcGFzc3dvcmQgZm9yIHZhbGlkYXRpb24KdmFsaWRfdXNlcm5hbWUgPSAidXNlcjEyMyIKdmFsaWRfcGFzc3dvcmQgPSAicGFzczEyMyIKCiMgQmVnaW4gSFRNTCBvdXRwdXQKcHJpbnQoIjxodG1sPiIpCnByaW50KCI8aGVhZD4iKQpwcmludCgiPHRpdGxlPkxvZ2luIFJlc3VsdDwvdGl0bGU+IikKcHJpbnQoIjwvaGVhZD4iKQpwcmludCgiPGJvZHk+IikKCiMKaWYgdXNlcm5hbWUgYW5kIHBhc3N3b3JkOgogICAgaWYgdXNlcm5hbWUgPT0gdmFsaWRfdX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