1. I login to the script (Cookie is created fine)
2. I try to use one of the features of the admin (each feature has it's own subroutine in the script), but it give me an internal server error(malformed header=<html>)
3. I try the logout button (logout cookie is created fine), but now I can just click on submit without entering my un/pw form the login page and it validates the user.
This is the code I used to create the login/logout cookies:
sub set_login_cookie { my $loggedIn=cookie(-name=>'loggedIn', -value=>'true', -expires=>'+30m', -path=>'/public_html/cgi-bin/cit/'); print header(-cookie=>$loggedIn); } sub set_logout_cookie{ my $loggedIn=cookie(-name=>'loggedIn', -value=>'false', -path=>'/public_html/cgi-bin/cit/'); print header(-cookie=>$loggedIn); }
Here is the code I used for the login page and the main page:
sub login_html { my $cookie = "cookie('loggedIn')"; print<<EndOfHTML; <HTML> <HEAD> <TITLE>Net Works Web Design - Client Invoice Tracker: Admin Logon</TIT +LE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1 +"> <link rel="SHORTCUT ICON" href="http://nw-webdesign.000k.net/images/Fa +vicon.ico"> </HEAD> <BODY BGCOLOR=#FFFFFF leftmargin="0" topmargin="0" marginwidth="0" mar +ginheight="0" link="#666699"> <div align="center"> <table width=780 border=0 cellpadding=0 cellspacing=0 height="383" bgc +olor="#FFFFFF"> <tr> <td rowspan=2> <img src="http://nw-webdesign.000k.net/images/index +_01.gif" width=165 height=35></td> <td colspan=2> <img src="http://nw-webdesign.000k.net/images/index +_02.gif" width=615 height=24></td> </tr> <tr> <td> <img src="http://nw-webdesign.000k.net/images/index_03.gif" w +idth=1 height=11></td> <td rowspan=2> <img src="http://nw-webdesign.000k.net/images/index +_04.gif" width=614 height=73></td> </tr> <tr> <td colspan=2 height="39"> <img src="http://nw-webdesign.000k.net/ +images/logo.gif" width=166 height=62></td> </tr> <tr> <td colspan=3 background="http://nw-webdesign.000k.net/images/link +s.gif"> <table width="100%" border="0" cellspacing="0" cellpadding="0" b +ackground="http://nw-webdesign.000k.net/images/links.gif"> <tr> <td width="37%" height="28" align="center" valign="bottom">< +font size="-1" color="#000000"><!--#INCLUDE VIRTUAL="/cgi-bin/date/da +tetime.cgi"--></font></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/about.htm">ABOUT US</a></stron +g></font></div></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/services.htm">SERVICES</a></st +rong></font></div></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/portfolio.htm">PORTFOLIO</a></ +strong></font></div></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/helpdesk/" target="_blank">HEL +P DESK</a></strong></font></div></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net">HOME</a></strong></font></div +></td> <td width="10%" height="28"><div align="center"> </div> +</td> </tr> </table> </td> </tr> <tr> <td colspan=3 height="233"> <table width="100%" border="0" cellspacing="0" cellpadding="10" +height="188"> <tr> <td height="212" valign="top"><h3><font color="#999999" face +="Geneva, Arial, Helvetica, san-serif"><strong>Client Invoice Tracker +: Administration Logon</strong></font></h3> <p><font face="Geneva, Arial, Helvetica, san-serif">Use th +e form below to login to the administration section to preform mainte +nace tasks and to update current invoices:</font></p> <form action="$actionaddress?login" method="po +st"> <table align="center" cellpadding="2" cellsp +acing="2"> <tr> <td><font size="2" face="Geneva, Arial, +Helvetica, san-serif">Username:</font></td> <td><input type="text" name="username">< +/td> </tr> <tr> <td><font size="2" face="Geneva, Arial, +Helvetica, san-serif">Password:</font></td> <td><input type="password" name="passwor +d"></td> </tr> <tr> <td colspan="2" align="center"><input ty +pe="submit" value="Submit"></td> </tr> </table> </form> </td></tr> </table> <!--#include virtual="/cgi-bin/logitpro/ +logitpro.pl?c_count"--> </td> </tr> <tr> <td colspan=3 height="14"> <div align="center"> <table width="100%" border="0" cellspacing="0" cellpadding="0" + height="35" align="center"> <tr> <td background="http://nw-webdesign.000k.net/images/index_ +08.gif" height="35"> <div align="center"><b><font face="Geneva, Arial, Helvet +ica, san-serif" size="1" color="#666699">Copyright© 2004/2005 <em>Net Works Web Design</em></font></b></di +v> </td> </tr> </table> </div> </td> </tr> </table> </div> </BODY> </HTML> EndOfHTML exit; }
sub admin_main { my $cookie = cookie('loggedIn'); if ($cookie eq "true"){ print<<EndOfHTML; <HTML> <HEAD> <TITLE>Net Works Web Design - Client Invoice Tracker: Administration</ +TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1 +"> <link rel="SHORTCUT ICON" href="http://nw-webdesign.000k.net/images/Fa +vicon.ico"> <style type="text/css"> <!-- .adminbutton { width: 120px; font-style: italic; font-weight: normal; } --> </style> </HEAD> <BODY BGCOLOR=#FFFFFF leftmargin="0" topmargin="0" marginwidth="0" mar +ginheight="0" link="#666699"> <div align="center"> <table width=780 border=0 cellpadding=0 cellspacing=0 height="383" bgc +olor="#FFFFFF"> <tr> <td rowspan=2> <img src="http://nw-webdesign.000k.net/images/index +_01.gif" width=165 height=35></td> <td colspan=2> <img src="http://nw-webdesign.000k.net/images/index +_02.gif" width=615 height=24></td> </tr> <tr> <td> <img src="http://nw-webdesign.000k.net/images/index_03.gif" w +idth=1 height=11></td> <td rowspan=2> <img src="http://nw-webdesign.000k.net/images/index +_04.gif" width=614 height=73></td> </tr> <tr> <td colspan=2 height="39"> <img src="http://nw-webdesign.000k.net/ +images/logo.gif" width=166 height=62></td> </tr> <tr> <td colspan=3 background="http://nw-webdesign.000k.net/images/link +s.gif"> <table width="100%" border="0" cellspacing="0" cellpadding="0" b +ackground="http://nw-webdesign.000k.net/images/links.gif"> <tr> <td width="37%" height="28" align="center" valign="bottom">& +nbsp;</td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/about.htm">ABOUT US</a></stron +g></font></div></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/services.htm">SERVICES</a></st +rong></font></div></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/portfolio.htm">PORTFOLIO</a></ +strong></font></div></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/helpdesk/">HELP DESK</a></stro +ng></font></div></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net">HOME</a></strong></font></div +></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/cgi-bin/cit/citadmin.cgi?logou +t">LOGOUT</a></strong></font></div></td> </tr> </table> </td> </tr> <tr> <td colspan=3 height="233"> <table width="100%" border="0" cellspacing="0" cellpadding="10" +height="188"> <tr> <td height="212" valign="top"><font color="#999999" face="Ge +neva, Arial, Helvetica, san-serif"><strong> <h3>CLIENT INVOICE TRACKER: ADMINISTRATION >> ADMIN OP +TIONS</h3> </strong></font> <font color="#999999" face="Geneva, Arial, Helvetica, san- +serif"> <p>Administration Options are as follows: </font> <div align="center"> <table width="90%" cellpadding="2" cellspacing="2"> <tr> <td width="19%"><form name="add" method="post" act +ion="$actionaddress?add"><input name="add" type="submit" class="admin +button" id="add" value="Add User"></form></td> <td width="81%">Adds a user to the Client Invoice +Tracker database. </td> </tr> <tr> <td><form name="add" method="post" action="$action +address?delete"><input name="delete" type="submit" class="adminbutton +" id="delete" value="Delete User"></form></td> <td>Deletes a user from the Client Invoice Tracker + database. </td> </tr> <tr> <td><form name="add" method="post" action="$action +address?editin"><input name="editin" type="submit" class="adminbutton +" id="editin" value="Edit Invoice"></form></td> <td>Edit a current client's Invoice information. < +/td> </tr> <tr> <td><form name="add" method="post" action="$action +address?editus"><input name="editus" type="submit" class="adminbutton +" id="editus" value="Edit User"></form></td> <td>Edit a current client's information. </td> </tr> <tr> <td><form name="add" method="post" action="$action +address?adminpasswd"><input name="adminpasswd" type="submit" class="a +dminbutton" id="adminpasswd" value="Admin Password"></form></td> <td>Change the administration password. </td> </tr> <tr> <td><form name="add" method="post" action="$action +address?userpasswd"><input name="userpasswd" type="submit" class="adm +inbutton" id="userpasswd" value="User Password"></form></td> <td>Change a current client's password. </td> </tr> </table> </form> <font color="#999999" face="Geneva, Arial, Helvetica, sa +n-serif" size="2"> </font></div> <font color="#999999" face="Geneva, Arial, Helvetica, san- +serif" size="2"> <p> </p> </font></td> </tr> </table> <!--#include virtual="/cgi-bin/logitpro/ +logitpro.pl?c_count"--> </td> </tr> <tr> <td colspan=3 height="14"> <div align="center"> <table width="100%" border="0" cellspacing="0" cellpadding="0" + height="35" align="center"> <tr> <td background="http://nw-webdesign.000k.net/images/index_ +08.gif" height="35"> <div align="center"><b><font face="Geneva, Arial, Helvet +ica, san-serif" size="1" color="#666699">Copyright© 2004/2005 <em>Net Works Web Design</em></font></b></di +v> </td> </tr> </table> </div> </td> </tr> </table> </div> </BODY> </HTML> EndOfHTML } else { &login_html(); } exit; }
And heres the code I used for the "add user" feature:
sub add_user{ my $cookie = "cookie('loggedIn')"; if ($cookie eq "true"){ print "Content-type: text/html\n\n"; print<<EndOfHTML; <HTML> <HEAD> <TITLE>Net Works Web Design - Client Invoice Tracker: Administration</ +TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1 +"> <link rel="SHORTCUT ICON" href="http://nw-webdesign.000k.net/images/Fa +vicon.ico"> </HEAD> <BODY BGCOLOR=#FFFFFF leftmargin="0" topmargin="0" marginwidth="0" mar +ginheight="0" link="#666699"> <div align="center"> <table width=780 border=0 cellpadding=0 cellspacing=0 height="383" bgc +olor="#FFFFFF"> <tr> <td rowspan=2> <img src="http://nw-webdesign.000k.net/images/index +_01.gif" width=165 height=35></td> <td colspan=2> <img src="http://nw-webdesign.000k.net/images/index +_02.gif" width=615 height=24></td> </tr> <tr> <td> <img src="http://nw-webdesign.000k.net/images/index_03.gif" w +idth=1 height=11></td> <td rowspan=2> <img src="http://nw-webdesign.000k.net/images/index +_04.gif" width=614 height=73></td> </tr> <tr> <td colspan=2 height="39"> <img src="http://nw-webdesign.000k.net/ +images/logo.gif" width=166 height=62></td> </tr> <tr> <td colspan=3 background="http://nw-webdesign.000k.net/images/link +s.gif"> <table width="100%" border="0" cellspacing="0" cellpadding="0" b +ackground="http://nw-webdesign.000k.net/images/links.gif"> <tr> <td width="37%" height="28" align="center" valign="bottom">& +nbsp;</td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/about.htm">ABOUT US</a></stron +g></font></div></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/services.htm">SERVICES</a></st +rong></font></div></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/portfolio.htm">PORTFOLIO</a></ +strong></font></div></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/helpdesk/">HELP DESK</a></stro +ng></font></div></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net">HOME</a></strong></font></div +></td> <td width="10%" height="28"><div align="center"><font color= +"#666699" face="Geneva, Arial, Helvetica, san-serif" size="1"><strong +><a href="http://nw-webdesign.000k.net/cgi-bin/cit/citadmin.cgi?logou +t">LOGOUT</a></strong></font></div></td> </tr> </table> </td> </tr> <tr> <td colspan=3 height="233"> <table width="100%" border="0" cellspacing="0" cellpadding="10" +height="188"> <tr> <td height="212" valign="top"><font color="#999999" face="Ge +neva, Arial, Helvetica, san-serif"><strong> <h3>CLIENT INVOICE TRACKER: ADMINISTRATION >> ADD A US +ER </h3> </strong></font> <p><font color="#999999" face="Geneva, Arial, Helvetica, s +an-serif">To add a client to the Client Invoice Tracker database, fil +l out all of the information below and click on the submit button:</f +ont> <form name="add" method="post" action="$actionaddress?addu +serwrite"> <table align="center" cellpadding="2" cellspacing="2"> <tr> <td align="right">Company Name:</td> <td><input name="cname" type="text" id="cname"> </td> </tr> <tr> <td align="right">E-mail Address:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td align="right">Client ID #:</td> <td><input name="clientid" type="text" id="clientid" +></td> </tr> <tr> <td align="right">Password:</td> <td><input name="password" type="password" id="passw +ord"></td> </tr> <tr> <td align="right"><input type="submit" name="Submit" + value="Submit"></td> <td><input type="reset" name="Reset" value="Reset">< +/td> </tr> </table> </form> <p><font color="#999999" size="2"></font></td> </tr> </table> <!--#include virtual="/cgi-bin/logitpro/ +logitpro.pl?c_count"--> </td> </tr> <tr> <td colspan=3 height="14"> <div align="center"> <table width="100%" border="0" cellspacing="0" cellpadding="0" + height="35" align="center"> <tr> <td background="http://nw-webdesign.000k.net/images/index_ +08.gif" height="35"> <div align="center"><b><font face="Geneva, Arial, Helvet +ica, san-serif" size="1" color="#666699">Copyright© 2004/2005 <em>Net Works Web Design</em></font></b></di +v> </td> </tr> </table> </div> </td> </tr> </table> </div> </BODY> </HTML> EndOfHTML } else { &login_html(); } exit; }
Any help with this is greatly appreciated,
Tylor
2005-01-15 Janitored by Arunbear - added readmore tags, as per Monastery guidelines
In reply to Trouble with cookies by titanic_fanataic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |