I wrote a simple script to make sure a user is authorized to access a webpage (roster of area youth soccer leauge) then if they are authorized it will show the roster. Here is my script with some stuff edited out. There is only one username and password that everyone will use.
<?php
$USER=$_POST[user];
$PASSWORD=$_POST[password];
#Make sure username or password aren't blank or incorrect
if ((!$USER) || (!$PASSWORD)) {
echo "Please return the the <a href=\" login page</a>. Username and/or password were blank.";
exit;
} else if (($USER != "******") || ($PASSWORD != "******")) {
echo "Please return to the <a href=\" page</a>. Username and/or password were incorrect.";
exit;
}
#If username and password are correct, setcookie for auth #into roster.php
#and redirect to roster.php
*Here is where the problem is. If i use setcookie() and header() it won't set the cookie. But it will redirect to the roster page. The roster page has a script that says if cookie auth == "***" echo a bunch of html else show that the user is not authorized and a link back to login.html
If I do setcookie(), comment out the header(), and uncomment the echo it will set the cookie then they can click the link. It works but I would like to make it automated. I'm fairly new to php and new to programming(this is my first script used for something besides practice). *
setcookie("auth", "**", time()+3600, "/", "*****.***", 0);
Header("Location: #echo "
#<html>
#<body>
#<h1>Authorized</h1>
#Click <a href \" to continue to the roster
#</body>
#</html>";
?>
If anyone could give any suggestions i would appreciate it.
Thanks,
Jon
<?php
$USER=$_POST[user];
$PASSWORD=$_POST[password];
#Make sure username or password aren't blank or incorrect
if ((!$USER) || (!$PASSWORD)) {
echo "Please return the the <a href=\" login page</a>. Username and/or password were blank.";
exit;
} else if (($USER != "******") || ($PASSWORD != "******")) {
echo "Please return to the <a href=\" page</a>. Username and/or password were incorrect.";
exit;
}
#If username and password are correct, setcookie for auth #into roster.php
#and redirect to roster.php
*Here is where the problem is. If i use setcookie() and header() it won't set the cookie. But it will redirect to the roster page. The roster page has a script that says if cookie auth == "***" echo a bunch of html else show that the user is not authorized and a link back to login.html
If I do setcookie(), comment out the header(), and uncomment the echo it will set the cookie then they can click the link. It works but I would like to make it automated. I'm fairly new to php and new to programming(this is my first script used for something besides practice). *
setcookie("auth", "**", time()+3600, "/", "*****.***", 0);
Header("Location: #echo "
#<html>
#<body>
#<h1>Authorized</h1>
#Click <a href \" to continue to the roster
#</body>
#</html>";
?>
If anyone could give any suggestions i would appreciate it.
Thanks,
Jon