Jump to content

sigmahokies

Members
  • Posts

    138
  • Joined

  • Last visited

Everything posted by sigmahokies

  1. I can't edit what i said in above. I am trying to protect this third page from manual web address by using session, but session_start(); just go an error. Thanks again, Gary
  2. Hi I'm back. I succeed to create the denial page if username and password are wrong and not exist, but i got problem with continue session by username, (of course, I won't continue the session by password). it get an error when conflict with header (redirect) and cache. There are three page that I am showing to you now. First page: <!doctype html> <html> <head> <title>Login System</title> <link href="rcd.css" rel="stylesheet" type="text/css"> <link href="font.css" rel="stylesheet" type="text/css"> <link href="submit.css" rel="stylesheet" type="text/css"> </head> <body> <form action ="checklogin.php" method="POST"> <center> <fieldset style='width:800px;'> <table cellspacing="10" cellpadding="10"> <p id="font">Please Login to RCD's database</p> <tr><td>Username:</td><td><input type="text" name="user" placeholder="Username"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" placeholder="Password"></td></tr> <tr><td colspan="2" align="center"><input id="submit" type="submit" name="submitted" value="Log in"></td></tr> </table> </fieldset> </center> </form> </body> </html> Second Page: <?php require_once("require.php"); session_start(); $username= stripslashes($_POST['user']); $password = stripslashes($_POST['pass']); $username = mysqli_real_escape_string($Garydb, $username); $password = mysqli_real_escape_string($Garydb, $password); $log = "SELECT username, password, type FROM username WHERE username ='".$username."' AND password = '".$password."'"; $result = mysqli_query($Garydb, $log); $count = mysqli_num_rows($result); if ($count == 1) { $_SESSION['user']; $_SESSION['pass']; header('location:register.php'); } else { die(header('location:denied.php')); } ?> <!doctype type> <html> </html> Third Page: <html> <?php require_once('require.php'); ?> <!doctype html> <head> <title>Register a new member</title> <link href="rcd.css" rel="stylesheet" type="text/css"> <link href="members.css" rel="stylesheet" type="text/css"> </head> <body> <?php session_start(); $_SESSION['username'] = $user; echo "<p>You are logged as ".$user."</p>"; ?> On this third page, I get an error message - Warning: session_start(): Cannot send session cache limiter - headers already sent I know I must write session_start(); on top of all php script, but I don't know why I gets error when I am got them right username and password. But yet, If someone typed wrong or not exist username and password will go to denied, it works. but i got error, session won't print on screen as you can see as logging. Can you help? Thank you in advance time. Gary
  3. Ok ok, you don't have to make bigger font size, ok? I am going to remove password in session... Done, removed.
  4. Hi everyone, I know you are seeing me post in here many times for help, but I am very very appreciate about you who helped me. This is better than Stack overflow website! However, I have last thing to do in login system. I succeed create login system - login page, check login page (make sure it is you or kill page), then go to restrict page, but i have problem with $_SESSION variable that continue to other page. I need something that can restrict to username to access to this page. I don't want to anyone type in manual in web address to access, I will label session in all restrict page, but seem my login page and check login page are working, but check login page could not pass to restrict area (pass to register page, edit page, delete page, etc). can you help? I wrote in PHP: <?php require_once("require.php"); session_start(); $username = stripslashes($_POST['user']); $password = stripslashes($_POST['pass']); $username = mysqli_real_escape_string($Garydb, $username); $password = mysqli_real_escape_string($Garydb, $password); $log = "SELECT username, password, type FROM username WHERE username ='".$username."' AND password = '".$password."'"; $result = mysqli_query($Garydb, $log); $count = mysqli_num_rows($result); if ($count == 1) { $_SESSION['username']; $_SESSION['passname']; header('location:register.php'); } else { die(header("location:denied.php")); } ?> <!doctype type> <html> </html> Then I wrote in next page that SESSION vailable should pass to this other page: <?php session_start(); if (isset($_SESSION['user']) && ($_SESSION['pass'])) { echo "<p>you are logged in ".$_SESSION['user']."</p>"; }else { die("<p>You don't have permission or access to this page</p> <p>You must log in to gain access <a href='login.php'>Return to Login page</a></p>"); ?> Thank you in advance time. Gary
  5. Never mind about my last comment, i found a way to do that.
  6. It is working now, but I need to load to other file that allow user view this website with approved username. I thought: load('register.php'); or file_get_contents('register.php'); - after $_SESSION['user']; and $_SESSION['pass']; Also, I labelled session_start() at top of script. Do you know code that will load to other page if correct username and password?
  7. Hi everyone, I am trying to set up the login system in PHP, seem function in PHP is not correctly, maybe I am missing something. Message from error said : Fatal error: Call to undefined function session_register() in. on line 20 Here my script in PHP: <?php require_once('require.php'); $username = $_POST['user']; $password = $_POST['pass']; $username = stripslashes($username); $password = stripslashes($password); $username = mysqli_real_escape_string($Garydb, $username); $password = mysqli_real_escape_string($Garydb, $password); $log = "SELECT username, password, type FROM username WHERE username ='".$username."' AND password = '".$password."'"; $result = mysqli_query($Garydb, $log); $count = mysqli_num_rows($result); if ($count == 1) { session_register('user'); <-- 20 line session_register('pass'); header('register.php'); } else { header("<p>Wrong or not exist username and password <a href='login.php'>Return to Login page.</a></p>"); } ?> <!doctype type> <html> </html> Is there something is missing that i should add in this script?
  8. Ch0cu3r, You are helpful! I can see what is wrong with MySQL, I just fixed it, now it is working, Thank you so much!
  9. Ch0cu3r, No No, that is not what I meant, I mean, I need to pass PHP variable to pass into SESSION, it is a login. I'm trying to learn to do code in the login system in PHP, I know it is not easy to build the login system. if this mysqli_fetch_all or mysqli_fetch_array can show the result from MySQL, then i will know it will go to SESSION, but it didn't. I put 'die("Could not work")' show that PHP variable didn't pass into a new statement.
  10. QuickCarOld, I added mysqli_real_escape_string where you showed me, but there is other situation that username and password didn't print in echo. I am using echo or print to make sure PHP variable are passing to other in statement, but it didn't get in statement, that's why i type 'die("Could not work"), it can tell me that PHP variable hasn't pass in other statement below of this statement. If PHP variable is passed into other state, then i can work on SESSION. But it didn't pass. I thought PHP variable would pass to echo to print on website, but it didn't. <?php if ($_POST['submitted']) { $username = $_POST['user']; $password = $_POST['pass']; if ($username && $password) { $log = "SELECT username, password, type FROM username WHERE username = '".mysqli_real_escape_string($Garydb, $username)."' AND WHERE password = '".mysqli_real_escape_string($Garydb, $password)."'"; $result = mysqli_query($Garydb, $log) or die("could not work"); echo "<p>".$result['username']."</p>"; } } ?> I need to see PHP variable to be print in echo in "echo "<p>".$result['username']."</p>"; but it didn't show the print in echo. Also, I created table name username, then I have four columns - ID, username, password, and type.
  11. Wow, seem i have to learn about login system - session, mysqli_real_escape_string and has_password. Sometimes, I don't understand what PHP and MySQL's manual website...I am appreciated that you advised me about those security in MySQL
  12. QuickOldCar, Okay, Where I should put mysqli_real_escape_string? after doing query? Yeah, I named table "username", then username, password, type are in columns on username table. Gary
  13. I am testing to see if PHP variables can pass from previous page to present page to login, I notice it doesn't work in MySQL query from previous to present page. It is like using ID to pass the variable in link like this: "?id=" in link, but I am using submit button. I typed name="user" in previous page, that should pass variable to present, then set up the select in database, but it doesn't do that, what i did do wrong? if ($_POST['submitted']) { $username = $_POST['user']; $password = $_POST['pass']; if ($username && $password) { $log = "SELECT username, password, type FROM username WHERE username = '".$username."' AND WHERE password = '".$password."'"; $result = mysqli_query($Garydb, $log) or die("could not work"); echo "<p>".$result['username']."</p>"; } } Also, I wonder about two query in one sentence, like using 'AND' on sentence, will it works? Please advise me. Thank you in advance time. Gary P.S. how do you type in chart like notepad++ in here? I need to know how to do that, so I show you in number line that you can point much easier to read.
  14. Oh I see...sometimes, MySQL manual doesn't explain very clear...so, I come here. But thank you Gary
  15. I notice one of video show in youtube.com. I saw someone type in phpmyadmin database table, prepare a column, typed in name "type", then in type column "ENUM", what are people using "ENUM" in type column in phpmyadmin for? Please advised me. Thank you, Gary
  16. Barand, your code is working now, but your code is not correctly, but i fixed it, finally, now it is working! Thank you, Barand!
  17. you are using OOP, I am using Procedural. That is why I don't get much from OOP. Is OOP and Proedural similar? your code in above of here doesn't work at all.
  18. Barand, EXACTLY what i am trying to make. Can you help?
  19. Hi Barand and Gizomla, I'm not sure I follow you, what i did do scipt in PHP in HTML: <!doctype html> <html> <head> <title>Local and Non-local Members</title> <link href="rcd.css" rel="stylesheet" type="text/css"> </head> <body> <table border="1" width="25%"> <tr><td><b><i>Local</i></b></td><td nowrap><b><i>Non-local</i></b></td></tr> <tr> <?php $local = "SELECT * FROM Members WHERE Local = 'Yes'"; $nonlocal = "SELECT * FROM Members WHERE Local = 'No'"; $local2 = mysqli_query($Garydb, $local); $nonlocal2 = mysqli_query($Garydb, $nonlocal); if (mysqli_num_rows($local2)) { while ($rows = mysqli_fetch_assoc($local2)) { echo "<tr><td nowrap>".$rows['FirstName']." ".$rows['LastName']."</td>"; if (mysqli_num_rows($nonlocal2)) { while ($row2 = mysqli_fetch_assoc($nonlocal2)) { echo "<td nowrap>".$row2['FirstName']." ".$row2['LastName']."</td></tr>"; } } } } ?> </tr> </table> </body> </html> This script just end up incorrect separate between local and nonlocal. I hope you can help...
  20. Order? It will go one columns, but i will like to have two columns on website that split from one column on the table. I created one column under "local" on the table, But I inserted a cell "yes" and "no" on one columns, so i will like to have split one to two columns on website that show separate the yes and no, one column show "yes" (true), the next columns show "no" (false). if you saying ORDER can split the yes and no as true and false into two columns? I will give it a try. P.S. I tried to insert two image to make clear example what I want to create, but seem this post doesn't have icon to insert an image...
  21. Hi Gizmola, I am trying to do is separate the yes and no from one columns that go to two columns. For example, I will like to have list of members are local, and list of member are non-local. I can put local and non-local on top of table, then list goes on under local, and list goes on under non-local that i created the one columns in database, i put some yes and no in one column under local on table in database. Get it? Please let me know if you need to understand what I said. Really, English is my second language. Thanks, Gary
  22. Hi everyone I'm getting somewhere in PHP, but I am still have long way to go. I want to ask you...is there possible to have two execute the query from database? For example - $one = "select FirstName, Lastname, Local FROM Members WHERE Local = 'Yes'"; (Local member) $two = "select FirstName, Lastname, Local FROM Members WHERE Local = 'No'"; (Non-Local member) if ($one && $two) { (mysqli_num_rows($one) && mysqli_num_rows($two)) That is my script, but is it possible to have split in two col for "Yes" and "No". Please let me know if it is possible or not... if not, it means, I have to do completely seperate script between Yes and No (true/false). Thank you, Gary
  23. Hi everyone, Anyone recommended me to learn how to set up the login system, it is most advanced system, even longer work. Anyone know link to website that can help me learning about login system? Video will be very appreciate... Thanks, Gary
  24. Sccostah, yeah, that is what I mean, Virtual Private Server...oops. Oh my friend who have more experience with it, he installed the security and manage system, include https. but he is not good at PHP, He is kind of different in special in IT. However, I just start in few years ago, I was in class, I always feel they are not teaching something else. Now, I was right. I am still learning from my friend. PHPstorm, I will go google it up... Thank you.
  25. Hi everyone, I need an advice about website and job. 1. which is better - Virtual Private Network or Shared-network (like GoDaddy.com). 2. what should I do If i want to have a job at web development - using coding or Adobe Dreamweaver CS6 or CC. I need to decide what is best for me to create my own website with PHP. I believe it is easier to create website with Adobe Dreamweaver, but I was told by experienced guy that Dreamweaver is no good to use, most companies are prefer to use using code than Dreamweaver. is that true? Please advise me. Thank you in advance time. Gary
×
×
  • Create New...

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.