Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
PHP Help
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Aercor" data-source="post: 170395" data-attributes="member: 7567"><p>Hello,</p><p>I am just starting to learn PHP, and I wanted to make a simple, non-mysql login to guard all my work at school so the noobs wouldn't take my work.</p><p> </p><p>Basically, I have the main login part, I just need two parts added. I can't get my session to work, so I'll stay logged in until the session is destroyed. Secondly, I wanted to make a redirect, if the user is logged in successfully, redirect to blank.php or something.</p><p> </p><p>I will be getting mysql access at school on tuesday, I was wondering how hard it'd be doing that, and having users be able to register and see work I place out for them, not all my stuff though.</p><p> </p><p>Here's a live preview: <a href="http://2craft.net/" target="_blank">http://2craft.net/</a></p><ul> <li data-xf-list-type="ul">Username: admin</li> <li data-xf-list-type="ul">Password: password</li> </ul><p>My code:</p><p> </p><p>[code]</p><p>Index.php:</p><p> </p><p><?php</p><p>session_start();</p><p>if($_SESSION['username'] == "username"){</p><p>header("Location: login.php");</p><p>}</p><p>?></p><p><!DOCTYPE html></p><p><html></p><p><head></p><p><title>Login</title></p><p> </p><p> <!-- Seo Information --></p><p> <meta name="description" content="Login Page"/></p><p> <meta name="keywords" content="Login, Page"/></p><p> <meta name="author" content="Tyler Schramm"/></p><p> <meta charset="utf-8"/></p><p> </p><p> <!-- Css Files --></p><p> <link href="css/style.css" rel="stylesheet" type="text/css"/></p><p></head></p><p><body></p><p><form action="login.php" method="post"></p><p> Username: <input name="username" type="text"><br></br></p><p> Password: <input name="password" type="password"><br></br></p><p> <input name="submit" value="Login" type="submit"></p><p> </form></p><p> </p><p> <div id="footer"></p><p> <p>Copyright 2012 &copy; Tyler Schramm. All rights reserved.</p></p><p> </div></p><p></body></p><p></html></p><p> </p><p>[/code]</p><p> </p><p>[code]</p><p>Login.php:</p><p> </p><p><?php</p><p>session_start();</p><p>if (isset($_POST['submit'])){</p><p>$_SESSION['username'] = $_POST['username'];</p><p>$_SESSION['password'] = $_POST['password'];</p><p> </p><p>if ($_SESSION['username'] == "admin" && $_SESSION['password'] == "password"){</p><p>echo "Well done, you have logged in successfully.";</p><p>} else {</p><p>echo "Sorry, the login information is incorrect.";</p><p>}</p><p>}</p><p>?></p><p> </p><p>[/code]</p></blockquote><p></p>
[QUOTE="Aercor, post: 170395, member: 7567"] Hello, I am just starting to learn PHP, and I wanted to make a simple, non-mysql login to guard all my work at school so the noobs wouldn't take my work. Basically, I have the main login part, I just need two parts added. I can't get my session to work, so I'll stay logged in until the session is destroyed. Secondly, I wanted to make a redirect, if the user is logged in successfully, redirect to blank.php or something. I will be getting mysql access at school on tuesday, I was wondering how hard it'd be doing that, and having users be able to register and see work I place out for them, not all my stuff though. Here's a live preview: [URL]http://2craft.net/[/URL] [LIST] [*]Username: admin [*]Password: password [/LIST] My code: [code] Index.php: <?php session_start(); if($_SESSION['username'] == "username"){ header("Location: login.php"); } ?> <!DOCTYPE html> <html> <head> <title>Login</title> <!-- Seo Information --> <meta name="description" content="Login Page"/> <meta name="keywords" content="Login, Page"/> <meta name="author" content="Tyler Schramm"/> <meta charset="utf-8"/> <!-- Css Files --> <link href="css/style.css" rel="stylesheet" type="text/css"/> </head> <body> <form action="login.php" method="post"> Username: <input name="username" type="text"><br></br> Password: <input name="password" type="password"><br></br> <input name="submit" value="Login" type="submit"> </form> <div id="footer"> <p>Copyright 2012 © Tyler Schramm. All rights reserved.</p> </div> </body> </html> [/code] [code] Login.php: <?php session_start(); if (isset($_POST['submit'])){ $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password']; if ($_SESSION['username'] == "admin" && $_SESSION['password'] == "password"){ echo "Well done, you have logged in successfully."; } else { echo "Sorry, the login information is incorrect."; } } ?> [/code] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
PHP Help
Top