Joomla! Custom form logs the user out on submission

余生颓废 提交于 2020-01-16 08:00:10

问题


I have the following php embedded into a Joomla! article, using the Sorcerer plugin;

<?php

$user = JFactory::getUser();
$username = $user->username;
$user_id = $user->id;
if (isset($_GET['action'])){

    date_default_timezone_set('Europe/London');    
    $user= JFactory::getUser();
    $username=$user->username;
    $user_id=$user->id;
    $date_now=date('m/d/Y H:i:s');

    $db =& JFactory::getDBO();
    $insert_sql= "INSERT INTO KOSRequest (user_id,created,IGN,LKL,KOSReason,Status) VALUES (".$user_id.",'".$date_now."','".$_POST['$IGN']."',". $_POST['LKL'].",'".$_POST$['KOSReason']."','Pending')";  
    $db->setQuery($insert_sql);    
    $db->execute(); 
    echo "A new KOS entry has been added by ".$username."<br />"; 

} else {   
    echo"
        <form name='kos_entry' action='http://www.ospalliance.org.uk/JOOM/2-uncategorised/51-kill-on-sight-form?action=submit' method='POST'>
            Player IGN <input type='text' name='IGN' required /><br />
            Player Location :<input type='number' name='LKL' required /><br />
            Reason: <textarea rows='4' cols='50' name='KOSReason'></textarea><br />
            <input type='submit' value='Sumbit'>";
}

?>

My issue is that whenever the submit button is pressed, Joomla! logs the user out with the system message:

You have been redirected to the home page following logout

I can directly access the hyper-link specified in the action clause.

NB The SQL itself does the insert correctly (only if I replace the $_POST variables directly (because $_POST never reaches that point, I have to replace the variables like this);

$IGN='SomeIGN';
$LKL=1200;
$KOSReason='some reason';

But the primary question is , why does the user get logged out from Joomla!?

I have many many other forms which use this same logic, which work fine.

One difference might be that the server was upgraded by the host recently.

Working Scripts were created prior to the upgrade , but I wouldn't know where/how the setup is different.

Please help!

来源:https://stackoverflow.com/questions/24930619/joomla-custom-form-logs-the-user-out-on-submission

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!