我正在尝试编写一个程序,该程序在允许我访问之前会询问我的名称和密码。不知何故我写错了
public function store(Request $request){
$filePath = $request->file('file')->getClientOriginalName();
$data= ['file_path'=>$filePath, 'user_id'=>1];
dd($request->session()->get("user"));
DB::table('user.photos')->insert($data);
echo "Record inserted successfully.";
}
答案 0 :(得分:1)
问题是您将password
设置为输入,然后通过将password
设置为toma
来休息,因此您需要删除password = "toma"
。
print("Enter your name:")
myName = input ()
if myName == "Akib":
print("Enter your password")
password = input()
if password == "toma":
print("Access granted")
else:
print("Not granted")
答案 1 :(得分:0)
password = "password" # store your password here
name = "name" # store your name here
input_name = str(input("> enter your name: "))
input_password = str(input("> enter your password: "))
if input_name == name and input_password == password:
print("access granted !")
else:
print("declined !")
可以按原样完成。希望这会有所帮助:)
答案 2 :(得分:0)
您可以像这样实现所需的功能!
在这种情况下,如果输入的名称不是“ Akib”,它甚至不会提示用户输入密码。
# prompt for name
myName = input("Enter your name: ")
# check if name is correct
if myName == "Akib":
# prompt for password
password = input("Enter your password: ")
# check if password is correct
if password == "toma":
print("Access granted")
else:
print("Not granted")
else:
print("Not granted")