Jump to content

unexpected $end


thunder708

Recommended Posts

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?

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.