Jump to content

syntax error


cspgsl

Recommended Posts

the following error is returned from the code below

Parse error: syntax error, unexpected '<' in ....line 19

the problem is between the <span></span>tags

darned if i can see it... i'm too new


[code]
<?
if ($_SESSION['loggedin'] === true):
    //do nothing
elseif (remembereduser()):
    loginremembereduser();
else:
    $form="";
    render_login_form();
endif;

function render_login_form() {
    global $form;
    $attribs = array();
    require_once "HTML/QuickForm.php";
    $form = new HTML_QuickForm('loginform', 'post', $_SERVER['PHP_SELF'],"",NULL,TRUE);
    $form->addElement("header", "","Login here");
    $form->addElement("hidden","freshtest", getfreshtestid());

<span style="color:darkblue;"<?Hello :
=empty($_SESSION['bsd_username'])?>" We'd really like to learn your name.  Please login or register" : $_SESSION['bsd_username'] . " ( ".$_SESSION['bsd_profession'] .")" >
</span>



$_SESSION['bsd_username'] . " ( ".$_SESSION['bsd_profession'] .")" ?</span>
    $form->addElement("text", "username", "Username:", $attribs);    
    $form->addElement("password", "pwd", "Password:", $attribs);
    $form->addElement("checkbox", "rememberme", "", "Remember me", $attribs);
    $buttons[] = &HTML_QuickForm::createElement("reset", "reset", "Clear");
    $buttons[] = &HTML_QuickForm::createElement("submit", "submit", "Login");
    $form->addGroup($buttons, null, null, " ");
    $form->addElement("link", "","", FULLPATH."?action=forgottenpassword","Forgotten your password?", $attribs);
    $form->addRule("username", "You must supply a username", "required");
    $form->addRule("pwd", "You must supply a password", "required");
    $form->registerRule('freshtest', 'callback', 'isfreshsubmission');
    $form->registerRule('passwordverify', 'callback', 'verifypassword');
    $form->addRule("freshtest", "You cannot use the backbutton to login", "freshtest");
    $form->addRule("pwd", "Either the username or password is incorrect", "passwordverify");        
    if ($form->validate()):
        return $form->process("login");

    else:
        $contents = '<div class="loginform">'. $form->tohtml().'</div>';
        require_once "template.php";
        exit;
    endif;
}
function login($value=null){
    global $form;
    unset($_SESSION['freshtest']);
    $_SESSION['loggedin'] = true;
    $_SESSION['username'] = $form->exportvalue("username");
    $rm = &$form->getelement("rememberme");
    setrememberme($rm->getchecked());
}
function setrememberme($state) {
    global $db, $dbusertable;
    if ($state === true):
        $str =  "setting oookie";
        $expiry = time() + 31536000;
        $dbexpiry = $expiry;
    else:
        $str =  "deleting cookie";
        $expiry = time()  -3600;
        $dbexpiry = null;
    endif;
    $result = $db->query("update $dbusertable set rememberme=? where username=?", array($dbexpiry, $_SESSION['username']));
    setcookie("bsd_username", $_SESSION['username'], $expiry);
}
function remembereduser() {
    global $db, $dbusertable;
    if (!isset($_COOKIE['bsd_username'])) return false;
    $num = $db->getOne("Select count(*) from $dbusertable where username=? and rememberme > ?", array (trim($_COOKIE['bsd_username']), time()));
    return ($num == 1);
}
function loginremembereduser() {
    $_SESSION['loggedin'] = true;
    $_SESSION['username'] = trim($_COOKIE['bsd_username']);
    setrememberme(true);
}    
function verifypassword($value) {
    
    //note you cannot use this for crypted passwords, but md5 passwords work ok.
    
    global $form, $db, $dbusertable;
    $pwd=trim($value);
    $submittedusername = trim($form->exportvalue("username"));
    $num = $db->getOne("select count(*) as cnt from $dbusertable where username=? and pwd=?", array($submittedusername, md5($pwd)));
    return  ($num == 1);
}
function logout() {
    unset ($_SESSION['username']);
    unset ($_SESSION['loggedin']);
    setrememberme(false);
}

?>
[/code]
Link to comment
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<span style="color:darkblue;"<?Hello :
=empty($_SESSION['bsd_username'])?>" We'd really like to learn your name. Please login or register" : $_SESSION['bsd_username'] . " ( ".$_SESSION['bsd_profession'] .")" >
</span>[/quote]

Quite a few things here -

I cannot tell if you meant to exit php prior to the <span> tag, if you did you are missing "?>" before the tag. If you didn't mean to exit php, then you do not have any echo command to actually produce the tag. This is your unexpected "<" error.

Looks like you are missing a ">" to close your <span> tag.

Also, it looks like you will receive additional errors, becuase it does not appear that you are using the echo command after you move back into php. You have "<?Hello :". But since you never exited php I am not sure what you are attempting there.

Depending on what you are wanting to do, you need to review this whole section, but it could be that you need to just setup your echo commands.

Hope that helps!
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.