Jump to content

Login System -- not working


radar

Recommended Posts

Okay so I did finally get my template system working but now I am having a problem with my login stuff.. and i cant figure it out.. been working on it for like 20 mins..

Here is my Index.php

[CODE]
<?php
include('../includes/template.php');
include('../includes/db.php');
include('../includes/functions.php');
$db = new sql_db(localhost, root, zoindok, cesite, false);
$tpl = new FastTemplate('../templates/cesite');
$username = "Guest";

switch($act) {
case '' :
if (!$submit) {
if ($username == "Guest") {
$tpl->define(array(login => "admin/login.tpl"));
$tpl->assign(error, 'note: you must first login in order to view the admin console');
$tpl->assign(php_self, $PHP_SELF);
$tpl->assign(username, '');
$tpl->assign(password, '');
$tpl->parse(MAIN, "login");
$tpl->FastPrint(MAIN);
} else {
echo "logged in";
}
} else {
// this is where I'm having trouble...
$name = $_POST['login_username'];
echo $name;
}
break;
}
?>
[/CODE]

and here is my login.tpl
[CODE]
<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style3 {font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #FF0000; }
-->
</style>
<div align="center">
  <p><img src="../templates/cesite/images/judo9.gif" width="150" height="150"><br>
    <br>
    <span class="style3">{error}</span></p>
  <form name="login" method="post" action="php_self">
    <table width="236" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="73"><div align="right"><span class="style1">Username &nbsp;</span></div></td>
        <td width="163"><label>
          <input name="login_username" type="text" value="username">
        </label></td>
      </tr>
      <tr>
        <td class="style1"><div align="right">Password&nbsp;&nbsp;</div></td>
        <td><input name="login_password" type="password" value="password"></td>
      </tr>
      <tr>
        <td class="style1">&nbsp;</td>
        <td> &nbsp;</td>
      </tr>
      <tr>
        <td class="style1">&nbsp;</td>
        <td><label>
          <input name="submit" type="submit" id="submit" value="Login">
        </label></td>
      </tr>
    </table>
  </form>
  <p>&nbsp;</p>
</div>

[/CODE]

As you can tell just a simple login for my admin console..  I need to be able to retrieve my strings from login_username and login_password but i cant get them..

When i use just $login_username it returns blank.  Same with $_REQUEST['login_username']; and $_POST['login_username']; so any help on this would be appreciated.. i cant figure it out..
Link to comment
https://forums.phpfreaks.com/topic/18754-login-system-not-working/
Share on other sites

^ IIANM, php automatically converts constants to string if no declaration is found.. but you should put the single quote to identify it as a string.

Use this code just to be safe
[code]
<form name="login" method="post" action="<?=$_SERVER['PHP_SELF']?>">
[/code]

and use this code to retrieve your data coz you set your form method property to POST

[code]
<?php
$username = $_POST['login_username'];
$password  = $_POST['login_password']
?>
[/code]
I actually did get it fixed..  it has nothing to do with the php_self -- the reason why i had to do that is because the templateing engine requires total seperation of php and html.. so i use the php_self to input the page.. but then i figured why not just change it to index.php since thats what it is always going to be....

I ended up having to almost totally rewrite the class for the templating engine...  so yeah whatever its all good it works now.. thx..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.