Jump to content

Archived

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

radar

Login System -- not working

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..

Share this post


Link to post
Share on other sites
I did some testing with this and it's not just this form it's all forms.. it really sucks!  someone please help..

Share this post


Link to post
Share on other sites
I'm not familiar with people putting "php_self" as part of the action.  Is this correct?

Share this post


Link to post
Share on other sites
change:
[code] <form name="login" method="post" action="php_self">[/code]

to:
[code]  <form name="login" method="post" action="$PHP_SELF">[/code]

Share this post


Link to post
Share on other sites
Correct me if Im wrong but shouldnt


$db = new sql_db(localhost, root, zoindok, cesite, false);
be
$db = new sql_db('localhost', 'root', 'zoindok', 'cesite', false);

Unless the first 4 are constants

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
i had this problem whith $php_self not working aswell like it should and i ended up changing it to the page self name aswell and it worked i wonder why ???

Share this post


Link to post
Share on other sites
Where I am using the classes and the templating engine -- The particular engine that I am using won't allow any php within the html... which is why I had the problem..  Not sure why you would have had the problem.

// Radar

Share this post


Link to post
Share on other sites

×

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.