当前位置: 动力学知识库 > 问答 > 编程问答 >

database - Checking data that is in a wamp server and in phpmyadmin

问题描述:

I am trying to make a chat system. What I need is python code that checks for a correct username and password or if it even exists in the phpmyadmin database. If the username and password is entered wrong then it would restart the script

and you would need to enter the password and username again.

This is what I have tried so far.

UsernameInput = input ("UsernameInput",)

PasswordInput = input ("PasswordInput",)

WrongUsername = ("Wrong Username")

WrongPassword = ("Wrong Password")

if(UsernameInput == "username" and PasswordInput == "password"):

print("Loged in sucsessfully")

else:

print("login failled")

网友答案:

WAMP is not a server but W-indows A-pache M-ySQL P-HP.

Apache is Web Server and MySQL is Database Server.

phpMyAdmin is only tool to manage MySQL database.

Apache needs module mod_CGI or mod_WSGI if you want to use Python to create web page in place of PHP.

Python needs module like MySQLdb to get access to MySQL and check username and login.


BTW: user lowercase for variable names and functions names

logged_in = False

while not logged_in:
    username_input = input("UsernameInput") # no need ,
    password_input = input("PasswordInput") # no need ,
    wrong_username = "Wrong Username" # no need ()
    wrong_password = "Wrong Password" # no need ()

    if username_input == "username" and password_input == "password":  # no need ()
        print("Loged in sucsessfully")
        logged_in = True
    else:
        print("login failled - try again")

print( "You are inside the program - do what you want" )
分享给朋友:
您可能感兴趣的文章:
随机阅读: