我想制作一个页面,我可以在此注册人们。但是,一般人只能注册管理员,而不能注册。我可以使用它并创建一个登录页面,但是现在我需要从注册页面阻止不是管理员的人。我目前有:
import datetime as dt
import matplotlib.pyplot as plt
import pandas as pd
while True:
try:
def plotgraph(year):
dfgraph=pd.read_excel
(r'C:\Users\Taylo\Downloads\graph_data.xlsx')
dfgraph=dfgraph.set_index(['Date'])
start_date=datetime.date(year,8,1)
end_date=datetime.date(year+1,2,1)
print(dfgraph[start_date:end_date].plot())
return
year=int(input("Enter an election year: "))
except ValueError:
print("Sorry, I didn't understand that.")
continue
if (year>1915):
df1=pd.read_excel
(r'C:\Users\Taylo\OneDrive\Documents\election_facts_excel.xlsx')
df2=df1.set_index('Year', drop = False)
print(df2.loc[year])
plotgraph(year)
continue
elif (year%2==1):
print(year,"is not an election year")
continue
elif (year<1916):
print("Data not available for elections before 1916.")
continue
我目前也有一个类似http://prntscr.com/lnauru的数据库设置 问题是人们仍然可以访问该页面。不管是“ Y”还是“ N”
答案 0 :(得分:-1)
if(isset($_POST['isAdmin'])){
$userid = $_POST['isAdmin'];
$query = "SELECT * FROM staff_users WHERE userName = '$userid' AND isAdmin = 'Y'";
$result = $dbc->query($query);
$row_cnt = $result->num_rows;
if ($row_cnt > 0){
$_SESSION['isAdmin'] = $userid;
}
}
if(!isset($_SESSION['userSession'])){
# redirect to the login page
header('Location: https://mywebsite.com/staff');
exit();
}
if ($_SESSION['isAdmin']=='N')
{
header('Location: https://mywebsite.com/isnotstaff');
exit();
}