When the user sign up it shows the if print statement with no value not the elif print statement. i tried to make a database but i have to set the form action into the php file and i am using CGI I Don't know how it should work! When the user sign up the output is
Hello None
What should I do??
#if the user login
if (Username==form.getvalue('Username') and Password==form.getvalue('Password')) :
print("Content-Type:text/html\r\n\r\n")
print("<html>")
print("<head>")
print("<title>Hello - Second CGI Program</title>")
print("</head>")
print("<body>")
print("<h2>Hello %s </h2>" % (Username))
print("</body>")
print("</html>")
#if the user sign up
elif (Username1==form.getvalue('Username1') and Email1==form.getvalue('Email1') and Password1==form.getvalue('Password1')):
print("Content-Type:text/html\r\n\r\n")
print("<html>")
print("<head>")
print("<title>Hello - Second CGI Program</title>")
print("</head>")
print("<body>")
print("<h2>You have signed up !</h2>")
print("<h4>Hello %s </h4>" % (Username1))
print("<h4>your email is:%s </h4>" % (Email1))
print("<h4>Your Password is: %s </h4>" % (Password1))
If all 3 conditions are true, then so are just 2 of them, so the if
condition will succeed.
You need to swap the order of the if
and elif
so that the more specific condition will be tested first.
if (Username1==form.getvalue('Username1') and Email1==form.getvalue('Email1') and Password1==form.getvalue('Password1')):
print("Content-Type:text/html\r\n\r\n")
print("<html>")
print("<head>")
print("<title>Hello - Second CGI Program</title>")
print("</head>")
print("<body>")
print("<h2>You have signed up !</h2>")
print("<h4>Hello %s </h4>" % (Username1))
print("<h4>your email is:%s </h4>" % (Email1))
print("<h4>Your Password is: %s </h4>" % (Password1))
elif (Username==form.getvalue('Username') and Password==form.getvalue('Password')) :
print("Content-Type:text/html\r\n\r\n")
print("<html>")
print("<head>")
print("<title>Hello - Second CGI Program</title>")
print("</head>")
print("<body>")
print("<h2>Hello %s </h2>" % (Username))
print("</body>")
print("</html>")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.