Jump to content


Photo

Login System -- not working


  • Please log in to reply
8 replies to this topic

#1 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 26 August 2006 - 09:46 PM

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

<?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;
}
?>

and here is my login.tpl
<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>


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

#2 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 27 August 2006 - 12:33 AM

I did some testing with this and it's not just this form it's all forms.. it really sucks!  someone please help..

#3 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 27 August 2006 - 01:45 AM

I'm not familiar with people putting "php_self" as part of the action.  Is this correct?
What is the CoronaMatrix?

#4 hax

hax
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 27 August 2006 - 01:53 AM

change:
<form name="login" method="post" action="php_self">

to:
  <form name="login" method="post" action="$PHP_SELF">


#5 High_-_Tek

High_-_Tek
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 27 August 2006 - 03:05 AM

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

#6 Aurorius

Aurorius
  • New Members
  • Pip
  • Newbie
  • 4 posts
  • LocationMalaysia

Posted 27 August 2006 - 04:00 AM

^ 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
<form name="login" method="post" action="<?=$_SERVER['PHP_SELF']?>">

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

<?php
$username = $_POST['login_username'];
$password  = $_POST['login_password']
?>


#7 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 27 August 2006 - 04:20 AM

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

#8 nadeemshafi9

nadeemshafi9
  • Members
  • PipPipPip
  • Advanced Member
  • 1,245 posts
  • LocationUK

Posted 27 August 2006 - 04:28 AM

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 ???
DONT LAY AN EGG OVER IT

#9 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 27 August 2006 - 05:11 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users