radar Posted August 26, 2006 Share Posted August 26, 2006 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]<?phpinclude('../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 </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 </div></td> <td><input name="login_password" type="password" value="password"></td> </tr> <tr> <td class="style1"> </td> <td> </td> </tr> <tr> <td class="style1"> </td> <td><label> <input name="submit" type="submit" id="submit" value="Login"> </label></td> </tr> </table> </form> <p> </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.. Quote Link to comment https://forums.phpfreaks.com/topic/18754-login-system-not-working/ Share on other sites More sharing options...
radar Posted August 27, 2006 Author Share Posted August 27, 2006 I did some testing with this and it's not just this form it's all forms.. it really sucks! someone please help.. Quote Link to comment https://forums.phpfreaks.com/topic/18754-login-system-not-working/#findComment-80957 Share on other sites More sharing options...
Corona4456 Posted August 27, 2006 Share Posted August 27, 2006 I'm not familiar with people putting "php_self" as part of the action. Is this correct? Quote Link to comment https://forums.phpfreaks.com/topic/18754-login-system-not-working/#findComment-80980 Share on other sites More sharing options...
hax Posted August 27, 2006 Share Posted August 27, 2006 change:[code] <form name="login" method="post" action="php_self">[/code]to:[code] <form name="login" method="post" action="$PHP_SELF">[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18754-login-system-not-working/#findComment-80983 Share on other sites More sharing options...
High_-_Tek Posted August 27, 2006 Share Posted August 27, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/18754-login-system-not-working/#findComment-80992 Share on other sites More sharing options...
Aurorius Posted August 27, 2006 Share Posted August 27, 2006 ^ 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] Quote Link to comment https://forums.phpfreaks.com/topic/18754-login-system-not-working/#findComment-80997 Share on other sites More sharing options...
radar Posted August 27, 2006 Author Share Posted August 27, 2006 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.. Quote Link to comment https://forums.phpfreaks.com/topic/18754-login-system-not-working/#findComment-81003 Share on other sites More sharing options...
nadeemshafi9 Posted August 27, 2006 Share Posted August 27, 2006 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 ??? Quote Link to comment https://forums.phpfreaks.com/topic/18754-login-system-not-working/#findComment-81006 Share on other sites More sharing options...
radar Posted August 27, 2006 Author Share Posted August 27, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/18754-login-system-not-working/#findComment-81013 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.