Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Login form doesn't show error

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Andreiasi Marian
Smarty n00b


Joined: 23 Nov 2018
Posts: 1

PostPosted: Fri Nov 23, 2018 12:41 pm    Post subject: Login form doesn't show error Reply with quote

I used a script for PTC and I changed the template with another one built with bootstrap, anyway, this login form doesn't work, it show the form but doesn't redirect to any page or show errors if user or password is wrong. Sorry for my english

I'm begginer with PHP, HTML, etc.

That is the login.tpl file:

Code:
{include file="header.tpl"}
<div class="site_content">
<div style="width:600px; margin:0 auto">
<div class="widget-title">{$lang.txt.loginacc}</div>
<form id="loginform" method="post" onsubmit="return submitform(this.id);">
<input type="hidden" name="token" value="{getToken('login')}" />
<input type="hidden" name="a" value="submit" />
   <table width="100%" class="widget-tbl">
       <tr>
           <td align="right" width="200">{$lang.txt.username}:</td>
            <td><input type="text" name="username" size="40" /></td>
      </tr>
        <tr>
            <td align="right">{$lang.txt.password}:</td>
            <td><input type="password" name="password" size="40" /></td>
        </tr>
        <tr>
        {if $settings.captcha_login == 'yes'}
           {if $settings.captcha_type == 1}
            <tr>
                <td></td>
                <td>{$captcha_login}</td>
            </tr>
            <tr>
                <td></td>
                <td><input type="text" name="captcha" id="captcha_login" size="40" /></td>
            </tr>
           {else}
            <tr>
               <td colspan="2" align="center">{$captcha}
                </td>
            </tr>           
            {/if}
        {/if}
        <tr>
           <td></td>
            <td><input type="submit" name="login" value="{$lang.txt.login}" /></td>
        </tr>
        <tr>
           <td colspan="2" align="center">
            <a href="./?view=forgot">{$lang.txt.forgotpassword}</a>
            {if $settings.register_activation == 'yes'}
            &nbsp;&nbsp;&bull;&nbsp;&nbsp; <a href="./?view=forgot&page=resend_activation">{$lang.txt.resendactivation}</a>
            {/if}
            </td>
        </tr>
    </table>

</form>
 
</div>
{literal}       
<script type="text/javascript">
$(function(){
loginkeyboard();     
});</script>       
{/literal}

</div>
<!-- End Content -->
         
{include file="footer.tpl"}


and here is login.php file

Code:
<?php

if (!defined("EvolutionScript")) {
   exit("Hacking attempt...");
}

require SMARTYLOADER;

if ($settings['captcha_login'] == "yes") {
   if ($settings['captcha_type'] == "1") {
      $captcha_login_html .= "<div style=\"padding:5px 0px\"><a href=\"javascript:void(0);\" onclick=\"captchareload2();\"><img src=\"modules/captcha/captcha.php?r=login\" id=\"captchaimglogin\" border=\"0\" /></a></div>
";
      $captcha_login_html .= "<script>function captchareload2(){
";
      $captcha_login_html .= "$(\"#captchaimglogin\").attr('src','modules/captcha/captcha.php?r=login&x=34&y=75&z=119&?newtime=' + (new Date()).getTime());
";
      $captcha_login_html .= "}</script>";
      require_once "modules/captcha/getcaptcha_login.php";
   }
   else {
      if ($settings['captcha_type'] == "2") {
         require_once "modules/reCAPTCHA/recaptcha.php";
      }
      else {
         if ($settings['captcha_type'] == "3") {
            require_once "modules/solvemedia/solvemedia.php";
         }
      }
   }
}


if ($input->p['a'] == "submit") {
   verifyajax();

   if (empty($input->p['username']) || empty($input->p['password'])) {
      serveranswer(0, $lang['txt']['invalidlogindetails']);
   }


   if (verifyToken("login", $input->p['token']) !== true) {
      serveranswer(0, $lang['txt']['invalidtoken']);
   }

   $captcha = strtoupper($input->pc['captcha']);

   if ($settings['captcha_login'] == "yes") {
      if ($settings['captcha_type'] == "1") {
         $verify = validate_captcha_login($captcha, "");
      }
      else {
         if ($settings['captcha_type'] == "2") {
            $resp = validate_captcha($_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
         }
         else {
            if ($settings['captcha_type'] == "3") {
               $resp = validate_captcha();
            }
         }
      }
   }

   $username = $db->real_escape_string($input->pc['username']);
   $password = $input->p['password'];
   $country = ip2country($_SERVER['REMOTE_ADDR']);
   $ip_user = $_SERVER['REMOTE_ADDR'];
   $sect = explode(".", $ip_user);
   $reip = $sect[0] . "." . $sect[1] . "." . $sect[2] . "." . $sect[3];
   $reipa = $sect[0] . "." . $sect[1] . "." . $sect[2] . ".*";
   $reipb = $sect[0] . "." . $sect[1] . ".*.*";
   $reipc = $sect[0] . ".*.*.*";
   $verifyusername = $db->fetchOne("SELECT COUNT(*) AS NUM FROM blacklist WHERE type='username' AND criteria='" . $username . "'");
   $ipban1 = $db->fetchOne("SELECT COUNT(*) AS NUM FROM blacklist WHERE type='ip' AND criteria='" . $reip . "'");
   $ipban2 = $db->fetchOne("SELECT COUNT(*) AS NUM FROM blacklist WHERE type='ip' AND criteria='" . $reipa . "'");
   $ipban3 = $db->fetchOne("SELECT COUNT(*) AS NUM FROM blacklist WHERE type='ip' AND criteria='" . $reipb . "'");
   $ipban4 = $db->fetchOne("SELECT COUNT(*) AS NUM FROM blacklist WHERE type='ip' AND criteria='" . $reipc . "'");
   $countryban = $db->fetchOne("SELECT COUNT(*) AS NUM FROM blacklist WHERE type='country' AND criteria='" . $country . "'");

   if ($verifyusername != 0) {
      serveranswer(0, $lang['txt']['usernameblocked']);
   }
   else {
      if ($ipban1 != 0 || $ipban2 != 0 || $ipban3 != 0 || $ipban4 != 0) {
         serveranswer(0, $lang['txt']['ipblocked']);
      }
      else {
         if ($countryban != 0) {
            serveranswer(0, $lang['txt']['countryblocked']);
         }
      }
   }

   $verifyuser = $db->fetchOne("SELECT COUNT(*) AS NUM FROM members WHERE username='" . $username . "'");

   if ($verifyuser == 0) {
      serveranswer(0, $lang['txt']['invalidlogindetails']);
   }

   $user_info = $db->fetchRow("SELECT id, username, password, status, country FROM members WHERE username='" . $username . "'");

   if ($user_info['password'] != md5($password)) {
      $bid = array("user_id" => $user_info['id'], "ip" => $ip_user, "status" => "Failed", "password" => $password, "date" => TIMENOW, "agent" => (!empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : $_ENV['HTTP_USER_AGENT']));
      $upd = $db->insert("login_history", $bid);
      serveranswer(0, $lang['txt']['invalidlogindetails']);
   }


   if ($settings['multi_login'] == "yes") {
      $checkip = $db->fetchOne("SELECT COUNT(*) AS NUM FROM members WHERE last_ip='" . $ip_user . "' AND id!=" . $user_info['id']);

      if ($checkip != 0) {
         $showip_error = "yes";
      }


      if ($showip_error == "yes") {
         serveranswer(0, $lang['txt']['multipleaccountsdetected']);
      }
   }


   if ($settings['multi_country'] == "yes") {
      if ($country != $user_info['country'] && $country != "-") {
         serveranswer(0, $lang['txt']['multiplecountrydetected']);
      }
   }


   if ($user_info['status'] == "Un-verified") {
      serveranswer(0, $lang['txt']['accountinactive']);
   }
   else {
      if ($user_info['status'] == "Suspended") {
         serveranswer(0, $lang['txt']['accountissuspended']);
      }
   }

   $cookie_id = strtoupper(md5(TIMENOW . $ip_user . $_SERVER['HTTP_USER_AGENT']));
   $set = array("last_ip" => $ip_user, "last_login" => TIMENOW, "status" => "Active", "cookie_id" => $cookie_id);
   $upd = $db->update("members", $set, "id=" . $user_info['id']);

   if (empty($user_info['computer_id'])) {
      include "includes/encrypt.php";
      $computerid = ascii2hex(substr(md5($user_info['username'] . $user_info['signup']), 0, 10));
      $upd = $db->query("UPDATE members SET computer_id='" . $computerid . "' WHERE id=" . $user_info['id']);
   }

   $bid = array("user_id" => $user_info['id'], "ip" => $ip_user, "date" => TIMENOW, "agent" => (!empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : $_ENV['HTTP_USER_AGENT']));
   $upd = $db->insert("login_history", $bid);
   $_SESSION['user_id'] = $user_info['id'];
   $_SESSION['password'] = $user_info['password'];
   $_SESSION['cookie_id'] = $cookie_id;
   setcookie("user_id", $user_info['id'], time() + 86400);
   setcookie("password", $user_info['password'], time() + 86400);
   setcookie("cookie_id", $cookie_id, time() + 86400);

   if ($verifyforum != 0) {
      $forum = $db->fetchOne("SELECT forum FROM forums WHERE status='Active' LIMIT 1");
      $forum_action = "login";
      include "modules/forums/functions/" . $forum . ".php";
   }

   serveranswer(1, "location.href='index.php?view=login&a=y';");
   exit();
}


if ($input->g['a'] == "y") {
   $smarty->assign("loginout_process", "login");
   $smarty->display("loginoutprocess.tpl");
   $db->close();
   exit();
   return 1;
}


if ($_SESSION['logged'] == "yes") {
   header("location: index.php");
   $db->close();
   exit();
}

$smarty->assign("captcha_login", $captcha_login_html);
$smarty->assign("login_class", "current");
$smarty->display("login.tpl");
$db->close();
exit();
?>
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Nov 24, 2018 9:04 pm    Post subject: Reply with quote

Smarty is a templating engine. I see nothing in your question that is related to Smarty, it's all generic PHP, and should be solved in your PHP code.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP