Login System - Help me OOPize it!
There is good script by KKeith
http://www.daniweb.com/forums/post951182.html
I want to use it as my base script with some modification. Before I customize it, I want to Make it OOPized into class with functions in functions.php and login+register.phps
Please help me on doing that! I'm intermediate btn newbee and intermediate developer :)
Thanks!
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
Oh!
Here is the test page I'm using to try do that after I OOPize them
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Consume Server: sfs-consume-2 -->
<?php
$test = '<big><b>* New PHP innovation award prize: PHP on Microsoft Visual Studio
</b></big>
Before I proceed with the main subject of this post, I would like to mention something that I did not have the opportunity to mention in prior posts.
The PHP Programming Innovation Award that happens every month on the PHPClasses site has a new prize that the winners may pick. It is the VS.PHP add-on. This is an add-on that allows you to use Microsoft Visual Studio as IDE for PHP. It was not developed by Microsoft, but rather by JCXSoftware.
';
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Login Script</title>
<link rel = "stylesheet" type = "text/css" href = "/site/site.css">
</head>
<body>
<table cellpadding = "5px", cellspacing = "0", border = "1px", align = "center", id ="table">
<tr>
<td colspan = "2"> <h2 style = 'text-align:center;'>MY CONTENT MANAGEMENT SYSTEM</h2> </td>
</tr>
<tr valign = "top">
<td width = "200px">
<center><b>Navigation Bar</b></center>
<?php
session_start(); //start session so we can login
//include both files
require('../site/admin/admin.login.php');
require('../site/admin/admin.register.php');
//from above file
//check if login is clicked, otherwise press register
if (isset($_GET['do'])){
switch($_GET['do']){
case 'login':
echo $html_login;
break;
case 'register':
echo $html_register;
break;
}// end switch
}//end if
else{
echo "<p>Member? <a href ={$_SERVER['PHP_SELF']}?do=login>Login</a>
Guest? <a href ={$_SERVER['PHP_SELF']}?do=register>Register</a></p>";
}//end else
echo "<div style=color:#ff0000'>{$message}</div>";
?>
</td>
<td> <?php echo $test; ?> </td>
</tr>
<tr>
<td colspan = "2" style = "text-align:center; background-color:black; color:white;"> Copyright © 2009, New Bee Technologies</td>
</tr>
</table>
</body>
</html>
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
1st off - to 'OOP'ize code, you need to
seperate views from the actual code. -->Please explain here what you mean
2nd - Use a database class [Done]
, an application class, and a main class.--> Explain a little, please!
3rd - Try to find a good templating system. I like phptal, and smarty works well too. --> I will check them thanks :)
You also can just include php files that are html with php variables in it, but no logic, like wordpress.--> Please explain
Thanks for your reply, but I need to understand what you are saying. Please explain to me with grain of salt!
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
I get it. I see people recommending smarty, but really I see it as mystery. Is there a newbie tutorial? Also back to my question, I see alot of things duplicating themselves in both register.php and login.php. would combining them into function be good idea?
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
I'm Making simple CMS for a site!
I will check that! I need secure Login/Register class. That is why I want to OOPize the one KKeith wrote and learn from there rather than reinverting the wheel.
I'm little busy with work now but when I get little time I will try to mess up with the files to come up with class. Hope Keith will help also:)
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392