Jump to content

desbest

Members
  • Posts

    117
  • Joined

  • Last visited

Posts posted by desbest

  1. I'm making some progress.

    I removed include("_header.php"); and include("_footer.php"); and now it logs into the right account.

    I will have to find out which of the header or footer is causing the problem, and which line of those files.

    Update

    I think what caused the problem is at the end of _footer.php I had <?php to start some php code but I never used ?> to close the php code so it caused a quirk

     

    2nd Update

    I have fixed the problem. The cache became faulty so I deleted the templates/ folder that was inside the cache and now it works.

  2. I ran tracy and got rid of all the errors and I still get the same problem of it logging into my "desbest" account instead of the account I specify.

    I have a related question. This page says to use $session->get() to get session variables.

    If that is true, then how come when I use $session->get("username"); it comes up as blank but when I use $session->username it doesn't come up as blank?

  3. I have just turned debug mode on and have printed the output of debug mode, so I could see if the session variables are being set correctly.

    It turns out the session variables are being set correctly, but still the account being logged into is my "desbest" superuser account instead of the "teststudent" account.

    5a0339701cea0_testoutputwithdebug.png.7d9391dce69ba04c3961e2ddd4d73808.png

     try {
             // echo "<br><h1>dauser[name] is </h1>".$dauser->name;
             // echo "<br><h1>dauser[pass] is </h1>".$dauser->pass;
             echo "<br><h1>session[username] is </h1>".$session->username;
             echo "<br><h1>session[dapassword] is </h1>".$session->dapassword;
    
            // $session->set("dapassword", "testpassword");
            // $session->set("username", "teststudent");
    
            // $task = $session->login($session->username, $session->dapassword); //use plaintext password
             // $task = $session->login("$session->username", "$session->dapassword");
            $task = $session->forceLogin($session->username); 
            if (!$task){ $notice = "Failed to login to your newly created user. Contact technical support."; }
        } catch(\Exception $e) {
            throw new WireException('Unable to login as user');
        }

    I have no idea why it's logging into a different account than what I specify, if I was logged out before going on the web page and showing debug mode says that the session variables are set to what they should be.

  4. forceLogin() does work but with my code, it logs into my "desbest" superuser account instead of the account I want the code to login into which is the user which has just been created.

    My code for the signup.php template file is 643 lines long, and it looks like I'll have to give someone my entire website for them to run it on their computer and fix it and I might have to pay them to fix it. As when I isolate the code to its minimal form, it works,  but when I use my 643 lines long signup.php template file, it fails to work and I cannot see what is wrong with my code or if there's a bug with processwire.

    Do you think I'll have to post a thread in the Jobs section of processwire?

  5. I have changed the variable from $session->password to $session->dapassword and It still doesn't work. Also I am using $session->username which is different from the "name" field used for the user template.

    5a02ff02c6a56_correctdetails.png.fefab69d16b48a60b3b2a15d0e562b01.png

     

    $dauser = new User();
    $dauser->pass =  $session->dapassword;
    $dauser->name = $session->username;
    $dauser->save();
    
    try {
         echo "<br><h1>dauser[name] is </h1>".$dauser->name;
         // echo "<br><h1>dauser[pass] is </h1>".$dauser->pass;
         echo "<br><h1>session[name] is </h1>".$session->name;
         echo "<br><h1>session[dapassword] is </h1>".$session->dapassword;
    
            $task = $session->login($session->username, $session->dapassword); //use plaintext password
            if (!$task){ $notice = "Failed to login to your newly created user. Contact technical support."; }
        } catch(\Exception $e) {
            throw new WireException('Unable to login as user');
        }

     

    The login details are correct but instead of logging into the user called "teststudent" with the correct password, it logs into my superuser account called "desbest".

    What is going on and how do I fix it?

  6. I've changed my code to check if $task is null or not, but the task isn't completing and I don't know why. If the details are correct, why isn't the user being logged into?

     

    Update

    Now it is logging into my superuser account instead of the account I specify, when I use $session->login

    I have displayed the variables on the web page I am using to login with the username and password, and it is logging into a completely different account that has a different username and password.

    What is going on?

  7. I cannot use $session->login() to login as a specified user, and it doesn't return false or null.

    Here is my code.

        try {
            echo "<br><h1>dauser[name] is </h1>".$dauser->name;
            echo "<br><h1>session[password] is </h1>".$session->password;
    
            $task = $session->login($dauser->name, $session->password);
    
            if ($task === false){ echo "failed to login"; }
    
            // $darealuser = $users->get($dauser->name); 
            // print_r($darealuser->getArray);
            // $users->setCurrentUser($darealuser);
            // $session->_user_id = $darealuser->id; 
        } catch(\Exception $e) {
            throw new WireException('Unable to login as user');
        }

    The name and password is correct, as I have printed it on the page to check it.

    I can enter a correct username and password, or an incorrect one, and it fails to login as the user, and it doesn't return true or false. The $session->login line fails to execute.

    What is going on?

  8. When I use the following code I get an error.

    <?php
    function test(){
        return $page->httpUrl();
        // return $wire->page->httpUrl();
    }
    $test = test();
    echo $test; 

    I get this error.

    Quote

    Error:     Call to a member function httpUrl() on null

    How do I fix it? How do I get the current page's url inside a function? The function is being stored on the same template file of the page being displayed.

  9. Yes but I'm not getting the title from the current page, so I can't use the $page ones.

    How do I change 

    $options = $fieldtypes->get('FieldtypeOptions')->getOptions("experienced_in")->title;

    to choose the ID I want, as there are multiple options and it keeps getting the first one. I want to choose a number of one of the array entries.

    I tried to add [0] or [1] to the line of code above, and it didn't work.

  10. When I upgrade from Processwire 2.8 to 3 I get an error.

    It says Error 500. I have commented out the "500 NOTE" section on .htaccess, I have checked the error log file in site/assets/logs and it's empty.

    How do I get the upgrade to work? Is it a namespace issue? I can't see anything in the upgrading instructions on how to fix it.

  11. Is there a way to get the v1 templates working on a processwire website? I really like the design of the v1 website.

    I cannot install the Skyscrapers with the v1 templates on Processwire 3.0.62 and I cannot replace the templates folder from dadish's skyscrapers profile with the templates from v1 to get it to work.

  12. Is there a way to store data in the same way as pages, but not appear as a page?

    I would like to store private messages using Processwire and the $page and $pages API provides a good way to do so. I know I can stop the fields inside pages from being visible in the admin panel, but is there a way to not have the page be seen in the Pages section, similar to how the Form Builder stores the entries to the forms without that being stored in the Pages section?

  13. I have found a fix for this. In HTML, whenever a checkbox is checked and is POSTed it has a value of "on". If the checkbox is unchecked it has no value.

    Here is the working code.

    <?php
    if($input->post->changesettings) {
    $deactivated = (isset($input->post->deactivated)) ? 1 : 0; $user->deactivated = $deactivated;
    }
    ?>
    
    <form method="POST" action="">
    <input type="checkbox" name="deactivated" <?php if ($user['deactivated'] == 1) echo "checked='checked'"; ?>>
    <input type="submit" name="changesettings" value="Change settings" class="bigbutton" />
    </form>

     

×
×
  • Create New...