Note that there are some explanatory texts on larger screens.

plurals
  1. PORegistration Security PHP
    primarykey
    data
    text
    <p>So i've been trying to make secure PHP login / registration scripts and so far without any kind of password encryption I have this:</p> <pre><code>if($_POST) { function GenericError() { echo '&lt;script type="text/javascript"&gt;window.location.href="error.php"&lt;/script&gt;'; } function CheckEmpty($param) { if($param == "" || $param == null) echo '&lt;script type="text/javascript"&gt;window.location.href="empty.php" &lt;/script&gt;'; } function AllYourBase() { mysql_connect("MyHost", "MyUsername", "MyPassword") or die(mysql_error()); mysql_select_db("MyDatabase") or die(mysql_error()); } $username = CheckEmpty($_POST['username']); $first = CheckEmpty($_POST['fname']); $last = CheckEmpty($_POST['lname']); if($_POST['password'] == $_POST['vpass']) $password = $_POST['password']; else echo '&lt;script type="text/javascript"&gt;window.location.href="pass.php"&lt;/script&gt;'; if($_POST['email'] == $_POST['vemail']) $email = $_POST['email']; else echo '&lt;script type="text/javascript"&gt;window.location.href="email.php"&lt;/script&gt;'; AllYourBase(); mysql_query("INSERT INTO Users (username, password, firstname, lastname, email) VALUES ('%s', '%s', '%s', '%s, '%s')", mysql_real_escape_string($username), mysql_real_escape_string($password), mysql_real_escape_string($first), mysql_real_escape_string($last), mysql_real_escape_string($email)) or die(GenericError()); echo '&lt;script type="text/javascript"&gt;window.location.href="win.php"&lt;/script&gt;'; } &lt;/pre&gt; </code></pre> <p>Does this seem right to you guys? Is there anything else I can do besides password encryption to make this more secure? Also, is there a better way to handle errors than making all these individual pages?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload