Jump to content

Bootstrap not working in login script?


FuturShoc
 Share

Recommended Posts

I've been using this same code on my site's homepage form without a problem.

However, I'm moving it to a stand-alone script called by the same form which is now on an interior page of the site. The script below is a plain PHP file that lives in a subfolder of the root directory.

I'm getting no errors including the PW index file, per bootstrapping, but my api calls don't seem to be working...

Can anyone help?

<?php

    $email = $_POST['email'];

    $password = $_POST['password'];

    include("../../index.php"); 

    if($email && $password) {

        if ($email == 'visitor') {

            $emailUser = $users->get("name=visitor"); 

        } else {

            $email = $sanitizer->email($email); 

            $emailUser = $users->get("email=$email"); 

        }

        

        if($emailUser->id) {

            $user = $session->login($emailUser->name, $password); 

            if($user) {

                  $session->redirect('/catalog'); 

                  //echo 'logged in';

            } else {

                echo "Login failed!";

            }

        } else {

            echo "Unrecognized email address";

        }

    }

?>

Link to comment
Share on other sites

Thank you, titanium. That seems to have done the trick for me, though this call gives me an internal server error:

wire('sanitizer')->email($email);

I had been referring to the API docs, but for some reason hadn't been using that syntax because it worked as-is on my site's home page... I wonder why it didn't require the wire() syntax...

Link to comment
Share on other sites

@FuturShoc: wire function (wire('api-var-name')) is needed outside PW template context where $sanitizer, $pages etc. API variables won't be defined. This is briefly explained in API docs too. Most commonly this affects functions, modules (where $this->pages etc. are also available) and bootstrapped scripts.

There's probably something about that internal server error in your log files (PW and/or Apache) so you definitely should check those first.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...