• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
  • entries
    23
  • comments
    30
  • views
    54295

PHP Login Page With SQL Support

Sign in to follow this  
Followers 0
RLS0812

1132 views

This is not the best written longin page ever written, but should give you a good idea how to write your own. This code includes it's own anti injection code, and also uses it's own session IDs.

The SQL.PHP file has mechanisms for auto building tables, deleting elements from tables and outputting what you have in your tables.

Index.htmlLogin Page ';}// End Of Declarationns if (!check("Sign_Up") and !check("Sign_In") and !check("Su_User_Name") and !check("Si_User_Name") and !isset($_COOKIE["ID"]) ){ echo "Welcome! Please sign in or sign up !
"; button("Sign_In","Sign In"); button("Sign_Up","Sign Up"); } if (check("Sign_In") ) {echo 'Please sign in here.

User Name:   Password:  

'; } if (check("Sign_Up") ) { echo 'Please do not use special characters.
Letters, numbers and _ allowed.
Lenght must be longer than 4 characters.

User Name:   Game Name:   Password:  

'; } if (check("Su_User_Name") and check("Su_Game_Name") and check("Su_Password") ){ if (!verify($_POST["Su_User_Name"]) or !verify($_POST["Su_Game_Name"]) or !verify($_POST["Su_Password"]) or strlen($_POST["Su_User_Name"]) < 5 or strlen($_POST["Su_Game_Name"]) < 5 or strlen($_POST["Su_Password"]) < 5 ) { echo "

Letters, numbers and _ only. Lenght must be greater than 4 characters.


"; button("x","<-- Back"); } else{ if (test("Login_Name",$_POST["Su_User_Name"]) ){ echo "User name taken.
"; button("x","<-- Back"); } elseif(test("Game_Name",$_POST["Su_Game_Name"]) ){ echo "Game name taken.
"; button("x","<-- Back"); } else{ $x = "1234567890abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXYZ"; $x2 = ''; for ($i = 0; $i < 21; $i++) { $x2 .= $x[rand(0, strlen($x) - 1)]; } mysqli_query($sql,"INSERT INTO ".$table." (Game_Name,Login_Name,Blarg,ID)VALUES('".$_POST["Su_Game_Name"]."','".$_POST["Su_User_Name"]."','" .$_POST["Su_Password"]."','".$x2."')"); echo "Account created !
"; $temp = mysqli_fetch_assoc(mysqli_query($sql,"SELECT * FROM ".$table." WHERE ID='".$x2."'") ); setcookie("ID",$temp["ID"], time()+3600); button("x","<-- Back"); } } } if (check("Si_User_Name") and check("Si_Password") ) { $tmp1 = strip($_POST["Si_User_Name"]); $tmp2 = strip($_POST["Si_Password"]); if (test("Login_Name",$tmp1) and test("Blarg",$tmp2) ){ echo "Logged in !
"; $temp = mysqli_fetch_assoc(mysqli_query($sql,"SELECT * FROM ".$table." WHERE Login_Name='".$tmp1."'") ); setcookie("ID",$temp["ID"], time()+3600); button("x","<-- Back"); } else{ echo "Bad name or password. Please try again.
"; button("x","<-- Back"); } } ?>

.
sql.php
.

'; }}if (isset($_COOKIE["ID"])){ $result = mysqli_query($sql,"SELECT ID FROM ".$table." WHERE ID='".strip($_COOKIE["ID"])."'"); if (mysqli_fetch_array($result)){ $temp = mysqli_fetch_assoc(mysqli_query($sql,"SELECT Game_Name FROM ".$table." WHERE ID='".strip($_COOKIE["ID"])."'") ); echo "Welcome " . $temp["Game_Name"] . " !
"; } else{ unset($_COOKIE["ID"]); back(); }} else{ back(); }// Table Handeling if ($update){if ( mysqli_query($sql, "SELECT 1 FROM ". $table . " ") ) { $get = mysqli_query($sql, "SHOW COLUMNS FROM " . $table); echo "

Existing columns


"; while ($col = mysqli_fetch_row($get)) { echo "Existing column: " .$col[0] . "
";} echo"

=====

"; for ($x=0; $x!= count($add); $x++){ if(!mysqli_query($sql,"SELECT ". $add[$x] ." FROM ".$table . " ") ){ mysqli_query($sql,"ALTER TABLE ". $table ." ADD ".$add[$x] . " TEXT "); echo "Adding column: ". $add[$x] . "
"; }} for ($x=0; $x!= count($sub); $x++){ if(mysqli_query($sql,"SELECT ". $sub[$x] ." FROM ".$table . " ") ){ mysqli_query($sql,"ALTER TABLE " . $table . " DROP COLUMN " . $sub[$x] . " "); echo "Removing column: ". $sub[$x] . "
"; }} echo"

=====

"; $get = mysqli_query($sql, "SHOW COLUMNS FROM " . $table); echo "

Modifyed columns


"; while ($col = mysqli_fetch_row($get)) { echo "Existing column: " .$col[0] . "
"; }}else{echo "Error: Table '" . $table . "' does not exist
";} } ?>

0
Sign in to follow this  
Followers 0


4 Comments


I don't know PHP very well but it looks like you're missing password hashing, which is kind of critical given how many people get it wrong. It would be nice for once to have examples that actually show the right thing to do with respect to password security, and unfortunately storing passwords in plaintext isn't it. At the very least you want to run a decent KDF and ideally you will pursue PCI compliance (if the service offered is worth the trouble).

 

I'm sorry but I cannot upvote this, even if it is just an example on how to design login pages it is still propagating bad practices and god knows how many websites are cobbled together from just these kinds of samples.

0

Share this comment


Link to comment

I don't know PHP very well but it looks like you're missing password hashing, which is kind of critical given how many people get it wrong. It would be nice for once to have examples that actually show the right thing to do with respect to password security, and unfortunately storing passwords in plaintext isn't it. At the very least you want to run a decent KDF and ideally you will pursue PCI compliance (if the service offered is worth the trouble).

 

 PHP has it's own built in methods for this ...

crypt();

http://www.w3schools.com/Php/func_string_crypt.asp

0

Share this comment


Link to comment

Agreed, password hashing is needed... say SHA256 hashing. With all the GPUs and bitcoin miners out there now, dictionary cracking is getting too easy, and some algorithms (MD5, SHA1?, all the older ones) have known flaws that make it even easier. Also, transmitting the password in cleartext is Very Bad... use SSL (https)... or at least use javascript to encrypt it, and a 'nonce' to prevent replay attacks. Yep, it's complicated and easy to screw up.

 

You're probably better off using Google/Facebook/etc login APIs... or piggyback on wordpress, phpbb, etc if you're using one of those anyway.

 

Also, if your site is behind a caching server, everyone will get the same $_COOKIE. There are workarounds but I think it's simpler to use AJAX and document.cookie (or localStorage) in javascript... that's what you need anyway if you deploy HTML5 games as static html like I do.

0

Share this comment


Link to comment

You have several major errors in your code.

1. Stripping and preg_match is not enough to escape data

2. I don't see your password encryption (use PHP 5.5 or higer and use password_hash())

3. You should not directly access super globals ($_POST) you should use input filters then santize your data

4. You should move away from mysqli and use PDO with prepared statements and bind parameters

 

Some minor things

1. You mix your HTML and PHP way too much.

2. You don't have to concatenate your select statements (SELECT $record FROM $table WHERE column = $column is fine)

3. You should avoid using global variables.

0

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now