
id
Members-
Posts
37 -
Joined
-
Last visited
Everything posted by id
-
Ok thanks. So i decided to do the switch statement under my members.php page... but of course something isn't working. The issue im getting is that when the 'module' = anything, then its using the case "login"... Example. If i type mysite.com/index.php?app=members&module=logout then its shows the form for mysite.com/index.php?app=members&module=login... I do however have a default case, and that ONLY works when no module is selected.. So only when its mysite.com/index.php?app=members.. <?php $module = isset($_GET['module']); switch($module) { case "login": echo " <table> <form action='includes/process_members.php?action=login' method='post'> <tr> <td>Username: </td> <td><input type='text' name='username'></td> </tr> <tr> <td>Password: </td> <td><input type='password' name='password'></td> </tr> <tr> <td><input type='submit' name='submit' value='login'></td> </tr> </form> </table> "; break; case "logout": header("location: includes/process_members?action=logout"); break; default: echo "<h1>Default Page!</h1>"; break; } ?>
-
Well thank you! I was making it too complicated by have a members folder inside a folder called app, then inside the members folder i would have another folder called module. I knew that their was a simple way in doing this. But you mention that using a switch statement isn't a very safe method to practice. Can you provide a link on a more secure way to do this? PS i tried google and all it do is bring me to either the same material that doesn't help or some complicated stuff.
-
Ok thanks, I figured it out!. However i ran to some trouble :/. 1. How would i be able run scripts inside of a folder. Example.... In my directory i have the following folders apps=>members=>modules=>login.inc.php... and i want it to work like this... - www.mysite.com/index.php?app=members&modules=login , which would go the login page. -From their once the user click login, it goes to mysite.com/index.php?app=members&modules=processing ... if it works then go back to the login page, if it goes there then go to the users account page. But i think their is a easier way in doing this, because most webpages have it where if the user want to go to their page then they can just go to mysite.com/account or mysite.com/members/account... my thing with that is how can i do that by using dynamic pages because those webpages just change the content but not the layout. For right now i understand .... $app_dir = 'app'; $apps = scandir($app_dir,0); unset($apps[0],$apps[1]); $app = $_GET['app']; if(in_array($app ,$apps)) { //This is the part that im having trouble with! I can echo out if the file exist, but i do not know how to go inside a folder then check the module. } 2. In each of my folders (that's isnt an application and which the user should not go in, like a config folder) and i include a index.php in it which should redirect the user to the home page. However this doesn't happen, it just get rid of my layout and keep the content that is suppose to be on my home page. 3. Do i have to do configuration for my wamp server in order to get .htaccess files to work? Its giving me an internal error 500 when i try to do a 404 redirect.
-
I found out my issue. I didnt know that i had to put a margin-bottom on both of my divs (comments, and todo list), i just thought that you had to put it on the div stuff... thanks.
-
Hello everyone, My question is how can i change up the content of a page without changing the page layout / style... Example, i have a layout for a site and the only thing that i want to be change is the content that is in a div element.. so its... <div id='header'>My logo </div> <div id='content'>content of page</div> <div id='footer'>Stuff that goes in a footer</div> and instead of re-adding the code for the header and footer, how can i just change the content area? Im not sure but i think you can do it with the get method.. so its something like www.mysite.com/index.php?app=members&module=login or something like that, which ONLY change the what is in the content div...
-
Hey everyone... I have a problem. I do not know how to space the the divs! I want to add a space inbetween the div stuff and the div members. Also i want to add a space from the sidebar and the footer just like their is a space from the container and footer. html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="css/main.css" type="text/css" rel="stylesheet" /> <title>EmporaTech</title> </head> <body> <div id='admin_bar'> (Admin | Login | Logout) </div> <div id='header'> <h1>Home Page</h1> </div> <div id='primary_nav'> <ul> <li><a href='index.php'>Home Page</a></li> <li><a href='#'>Forums</a></li> <li><a href='#'>Member's Page</a></li> <li><a href='#'>Account</a></li> <li><a href='#'>Extras</a></li> </ul> </div> <div id='content'> <h1><center>Welcome Back , Lamar!</center></h1> <div id='container'> <div class='stuff'> <div id='todo_list'> <h1><center>To-do List</center></h1> <ul> <li>Create Outline for Webpage (css)</li> <li>Create Membership Script (Register, Login, Logout)</li> <li>Create a Profile script (User can edit account, view others account, remove account)</li> <li>Create member's application (Display a list full of members, Allow different account (Admin, Moderator, etc..), and more to come! )</li> </ul> </div> <div id='comments'> <h1><center>Comments</center></h1> <p>Outline is finished! Now to just do the memberships!</p> </div> </div> <div id='members'> <h1>Membership Application</h1> <ol> <li>Create login system</li> <li>Create logout system</li> <li>Create Registration</li> <li>Edit the website, and perform a check for a session to alter the links in the admin bar.</li> <li>Create a member's page which displays the user information</li> </ol> </div> </div> <!-- END CONTAINER TAG!--> <div id='sidebar'> </div> <!-- END THE SIDEBAR TAG!--> <div id='footer'> <p>Copyright Empora Tech 2012</p> </div> </div><!-- END THE CONTENT TAG! --> </body> </html> css @charset "utf-8"; /* Copyright EmporaTech */ /************************* For whole page! Create new css file for future applications! ***********************/ /* Notes * Colorwares: Green - #6C9 , Gray - #999 & #666! */ /* Main Content */ body { padding: 0px; margin: 0px; color: black; background-image:url(images/background.gif); background-size: 100%; } /* Admin Bar*/ #admin_bar { background-color:#CCC; text-align: center; height: 25px; border-top: solid thin #333; border-bottom: solid black thin; } /* Header */ #header { padding: 10px; margin: 0px; height: 105px; background-color: #999; border-bottom: #333 solid thin; text-align: center; box-shadow: inset 0px -10px 20px 0px #666; } /* Primary Navigation */ #primary_nav { padding: 0px; margin: 0px; border-bottom: thin solid #333; } #primary_nav ul { margin: 0px; padding: 0px; list-style-type: none; overflow: hidden; background-color: #999; } #primary_nav li { display: block; } #primary_nav a { float: left; width: auto; padding: 10px 10px; color: #333; border-right: thin solid #333; } #primary_nav a:hover { background-color: #F90; } /* Body Section */ #content { padding:10px; margin-left: 125px; width: 80%; float: left; border: #CCC thin solid; background-color: white; -webkit-box-shadow: 0px 0px 20px -10px #000; box-shadow: 0px 0px 20px -10px #000; } #container { width: 79%; float: left; } .stuff { margin: 0px; padding: 0px; clear: both; } #todo_list { float: left; width: 50%; height: 250px; border: #999 solid thin; border-radius: 15px 15px 15px 15px; } #comments { float: right; width: 49%; height: 250px; border: #999 solid thin; border-radius: 15px 15px 15px 15px; } #members { padding: 10px; margin: 0px; clear: both; height: auto; border: thin #999 solid; border-radius: 15px 15px 15px 15px; } #members h1 { text-align: center; } /* Side Bar */ #sidebar { width: 20%; min-height: 500px ; float: right; border:black thin solid; } /* Footer */ #footer { clear: both; border-top: #333 solid thin; text-align: center; color: #6C9; }
-
To the person who ask about the error, im getting nothing (literally). And so your saying i have to initialized the username and password? If so, then what would i initialized them with?
-
Ok so i been experimenting with some code (basic code, so no advance stuff nor any security measurements like md5,etc...) and i can not get this simple script to work. So this is how its suppose to go; on the index.php page, you login, which goes to process.php which runs the function of the functions.php page, etc.. You guys are smart and knows what the program is doing. However, it is not working right. I assume that my issue comes from my function.php page where i do the public function... index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Login Page!</title> </head> <body> <?php if(isset($_SESSION['username'])) { //Already logged in member! header("location: members.php"); } ?> <table> <form action='process.php' method='post'> <tr> <td>Username: </td> <td><input type='text' name='username' /></td> </tr> <tr> <td>Password: </td> <td><input type='password' name='password' /></td> </tr> <tr> <td> <input type='submit' value='login' name='submit' /> </td> </tr> </form> </table> </body> </html> process.php <?php include("functions.php"); //Process for each form! if(isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; $members->check_login($username,$password); $members->login(); } if(isset($_POST['submit_logout'])) { $members->logout(); } ?> functions.php <?php include ("config.php"); //Classes and functions! class memberssystem { var $username, $password; function check_login($username,$password) { $result = mysql_query("SELECT * FROM member WHERE username ='$username'") or die(mysql_error()); $check_rows = mysql_num_rows($result) or die(mysql_error()); if($check_rows != 1) { return 0; } else { while($row = mysql_fetch_array($result)) { if($row['username'] != $username || $row['password'] != $password) { return 1; } else return true; //Success! } } } public function login() { if($this->check_login($this->username,$this->password) == 0) { die("Username doesn't exist!"); } else if($this->check_login($this->username,$this->password) == 1) { die("Sorry but the combination doesn't match"); } else { $_SESSION['username'] = $this->username; header("location: members.php"); } } public function logout() { session_destroy(); header("location: index.php"); } } $members = new memberssystem; ?> config.php <?php //Configuration File session_start(); define("DB_HOST","localhost"); //Define Host define("DB_USER","root"); //Define Username define("DB_PASS",""); //Define Password define("DB_TABLE","practice5"); //Define the table that is being used. //Connect to the Server $connection = mysql_connect(DB_HOST,DB_USER,DB_PASS) or die (mysql_error()); //Connect to the Databse mysql_select_db(DB_TABLE,$connection); ?> members.php <?php //Member's Page! if(!$_SESSION['username']) { header("location: index.php"); } ?> <html> <h1>Member's Page!</h1> <p>Welcome to the Member's Page! For right now, you can not do anything :/ but you can <a name='submit_logout' href='process.php'>logout</a> :} </p> </html>
-
Im no pro, but for me for your 1st question it suppose to be: <html> <?php echo "<br />Hello" ?> </html> In php you can add html tags inside of echo's just like my example above. For you second issue, the post method doesn't show on the url only the "get" method does. The post method is mainly used for more secure items; like usernames, passwords, etc... While the get method is normally used to display certain items... Example, if you have a forum board or something similar, then in order to display a member's profile you would do www.site.com/userid=1 for the url, and to go onto a different member then you would simply change the url to do that. While if you was to login then you would use the post method in order to keep your information secure. Again im no pro but i hopes this helps.
-
Ok thanks! I got the idea of it.
-
Well thats the thing, alot of people do it differently. I would like for if its successful then simply set up a valid session and redirect it to a different page, but if it fails then simple point of the error. Im trying to start with a simple webpage, then build upon it so it can be complex.
-
Ok so i'm new to classes in php and i have a question. I'm working on a login / registration script in php,and i want to know what is the purpose of a class? Is it worth making? I been trying to find the benefits of making a class, but i don't see any because all i found was that it makes the code "looks" neat. My goal is to make a simple website (for practice), that would allow members to register to the database, then they would be able to login. Once login, the members would be allow to edit their profile and so on. Nothing complicated. However, when i try to set up a class and functions it get complicated. Example, I have a function called check_user, which would connect to the DB and verify that the user exist and if so then see if the passwords match. However, if the username doesn't exist or the user exist but the password doesn't match or if the user and pass matches then what do i return? Do i return a number value and if then what do i do with that number? :confused: :confused: :confused: