thunder708 Posted February 25, 2010 Share Posted February 25, 2010 i keep getting the error: unexpected $end on line 56 which is the last line of my code, i have thoroughly checked otu the code makign sure all { having matching } but cant explain why i get this error. here is my code: <? session_start(); if(!session_is_registered(admin)){ $a=1;} ?> <LINK href="style.css" rel="stylesheet" type="text/css"> <? if($a==1){ ?> Please Provide Your Password to gain Access<br> <form action="media?do=login" method="post"> <input type="hidden" value="1" name="1"> <input type="password" name="pass"><input type="submit" value="login"> </form> <? } else { $do = $_REQUEST['do']; if ($do == "login") { login(); } elseif ($do == "cd") { cd(); } elseif ($do == "dvd") { cd(); } elseif ($do == "games") { cd(); } echo "<a href='?do=cd'>Cd</a> | <a href='?do=games'>Games</a> | <a href='?do=dvd'>DVD</a> | } function login() { $pass = $_POST[pass]; if($pass == 'mypass'){ session_register('admin'); header('location:media.php'); } else { $data = 'Wrong Password'; return $data; } } function cd() { $data = 'cd'; return $data; } function dvd() { $data = 'dvd'; return $data; } function games() { $data = 'games'; return $data; } any ideas? Quote Link to comment Share on other sites More sharing options...
KrisNz Posted February 25, 2010 Share Posted February 25, 2010 You're missing a double quote. I'll let you find it Quote Link to comment Share on other sites More sharing options...
thunder708 Posted February 25, 2010 Author Share Posted February 25, 2010 if its this bit $pass = $_POST[pass]; when i try $pass = $_POST['pass']; i get error : unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING Quote Link to comment Share on other sites More sharing options...
thunder708 Posted February 25, 2010 Author Share Posted February 25, 2010 never mind......found it lol Thank you for pointing it out tho =D Quote Link to comment Share on other sites More sharing options...
thunder708 Posted February 25, 2010 Author Share Posted February 25, 2010 sorry didnt want to make new thread cos its same code casuing the problem.... also, the password isnt being transferred to the login() function. the form action should be media.php?do=login, i have altered this in my code before anyone says anything any ideas? Quote Link to comment Share on other sites More sharing options...
KrisNz Posted February 25, 2010 Share Posted February 25, 2010 $a will always equal 1 in your code, your login function never gets called. Maybe do a search for some login tutorials to help you along. Quote Link to comment Share on other sites More sharing options...
thunder708 Posted February 25, 2010 Author Share Posted February 25, 2010 i know how to do a login script, this script works if i refer it to a seperate page instead of using it as a function but i dont want that, i want it all on one page as i cant be doing with multiple pages for a simple application of php. i wouldnt be asking for help on a scripting forum if i could find it in a tutorial would i? if you can find me a suitable tutorial that uses form data and functions, be my guest. Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 25, 2010 Share Posted February 25, 2010 With the changes you have been making, can you post what your code looks like now, and what problems you are still having. Quote Link to comment Share on other sites More sharing options...
thunder708 Posted February 25, 2010 Author Share Posted February 25, 2010 sorry for delay i have been at college heres the code i have attempted and its not working and i know i have // before the stylesheet btw <? session_start(); if(!session_is_registered(admin)){ $a=1;} /* ?> <LINK href="style.css" rel="stylesheet" type="text/css"> <? */ if($a==1){ ?> Please Provide Your Password to gain Access<br> <form action="media.php?do=login" method="post"> <input type="hidden" value="1" name="1"> <input type="password" name="pass"><input type="submit" value="login"> </form> <? } else { $do = $_REQUEST['do']; $pass = $_REQUEST['pass']; if ($do == "login") { login($pass); } if ($do == "cd") { cd(); } elseif ($do == "dvd") { cd(); } elseif ($do == "games") { cd(); } echo "<a href='?do=cd'>Cd</a> | <a href='?do=games'>Games</a> | <a href='?do=dvd'>DVD</a>"; } function login($pass) { session_start(); if($pass == 'mypass'){ session_register('admin'); header('location:media.php'); } else { $data = 'Wrong Password'; return $data; } } function cd() { echo "CD"; } function dvd() { $data = 'dvd'; return $data; } function games() { $data = 'games'; return $data; } i even bypassed the login just to test out the other functions but when clicking on the link it doesnt show anything Quote Link to comment Share on other sites More sharing options...
thunder708 Posted February 25, 2010 Author Share Posted February 25, 2010 i think i know where i have gone wrong....ill let you know once ive figured it out Quote Link to comment Share on other sites More sharing options...
thunder708 Posted February 25, 2010 Author Share Posted February 25, 2010 i got my else in the wrong place cant believe i didnt notice that lol <? session_start(); if(!session_is_registered(admin)){ $a=1;} function login($pass) { $pass = $_REQUEST['pass']; if($pass == 'mypass'){ session_start(); session_register(admin); header('location:media2.php'); echo "success!"; } else { $data = 'Wrong Password'; return $data; }} /* ?> <LINK href="style.css" rel="stylesheet" type="text/css"> <? */ $do = $_REQUEST['do']; $pass = $_REQUEST['pass']; if($a==1){ ?> Please Provide Your Password to gain Access<br> <form action="media2.php?do=login" method="post"> <input type="hidden" value="1" name="1"> <input type="password" name="pass"><input type="submit" value="login"> </form> <? if ($do == "login") { login($pass); } } else { if ($do == "cd") { cd(); } elseif ($do == "dvd") { cd(); } elseif ($do == "games") { cd(); } echo "<a href='?do=cd'>Cd</a> | <a href='?do=games'>Games</a> | <a href='?do=dvd'>DVD</a>"; } function cd() { echo "CD"; } function dvd() { $data = 'dvd'; return $data; } function games() { $data = 'games'; return $data; } thanks for all help though Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.