Update: I found a working example, but when I tried to use it in the same situations I've been trying, it didnt work. So I think it is related to using .tpl files (templates). So I am going to try and display my form before the template is applied. That should solve it, thanks again.

thanks for your source example, may I ask, which include\require is needed for this: $forum_user['is_guest']  ??

Hi guys, I have spent well over a week on this one part, which is getting my website to log a user into the forum. I've read many articles and tried countless source code examples. I run into a lot of confusions, since it appears that the code has changed over the years so the old examples may no longer work?

Here's some of my confusions:
Some write "include", some write "require"
Some include "functions.php", some include "common.php". still not sure which ones I need.
I am using this:

require FORUM_ROOT.'include/common.php';

Some write "FORUM_ROOT", some write "PUN_ROOT"
I am using this:

if(!defined('FORUM_ROOT')) define('FORUM_ROOT', '/home/sites/example.com/public_html/forums/');
//in my source I have the correct domain instead of example.com

// and these too:
if(!defined('FORUM_TURN_OFF_MAINT')) define('FORUM_TURN_OFF_MAINT', 1);
if(!defined('FORUM_QUIET_VISIT')) define('FORUM_QUIET_VISIT', 1);

I also put these in, not sure if thats right:

$forum_page['redirect_url'] = "/index.php";
$forum_page['form_action'] = forum_link($forum_url['login']);
$forum_page['hidden_fields'] = array(
  'form_sent'=> '<input type="hidden" name="form_sent" value="1" />',
  'redirect_url' => '<input type="hidden" name="redirect_url" value="'.forum_htmlencode($forum_page['redirect_url']).'" />',
  'csrf_token' => '<input type="hidden" name="csrf_token" value="'.generate_form_token($forum_page['form_action']).'" />'
);

lastly the form:

<form method="post" action="<?php echo $forum_page['form_action'] ?>">
    <?php echo implode("\n\t\t", $forum_page['hidden_fields'])."\n" ?>
 
    Username:
    <input type="text" id="fld1" name="req_username" value="" />
    <br />
 
    Password:
    <input type="password" id="fld2" name="req_password" value="" />
    <br />
 
    <input type="checkbox" id="fld3" name="save_pass" value="1" />
    <label for="fld3">Remember me</label>
    <br />
 
    <input type="submit" name="login" value="Login" />
</form>

I feel like its almost working, any advice would be massively appreciated.