Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've had these problems before, it generally takes a little sussing as MySQL errors don't show up as PHP errors - and so aren't printed to the page. Personally I'd make use of MySQLi with PHP as it has greater support for several things, just do a google search if you want specifics, sometimes SQL can just need wrapping the table and database names in queries with ` characters (left of 1 key on windows keyboards)</p> <p>Try using the following code instead:</p> <pre><code>&lt;?php // Init databse connection $db_handle = new mysqli("mysql6.000webhost.com","username","password","Peoples") or die("Database connection error"); // check connection if ($db_handle-&gt;connect_errno) { printf("Connect failed: %s\n", $mysqli-&gt;connect_error); exit(); } // Strip function for query string function test_input($data){ $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $username = test_input($_POST["username"]); $email = test_input($_POST["email"]); $password = $_POST["password"]; $registered=0; // Try insert query, sometimes wrapping the table name in ` characters solves the issue - only use on database and table names not values if($result = $db_handle-&gt;query("INSERT INTO `users` (username,password,email,registered) VALUES ('$username','$password','$email','$registered');")) { echo 'Records added to the database'; // free result set $result-&gt;close(); } else { echo 'Database NOT Found'; } $db_handle-&gt;close(); ?&gt; </code></pre> <p>Also it's good practice to unset($var); 's but to be honest if you're expecting little traffic it's nothing really to worry about.</p> <p>If you are holding user data in your database, holding raw passwords can upset people and you really shouldn't do it in the event that data gets stolen from you and then you have to explain to all your users why someone is running around with the username and password they like to use for everything they login to.</p> <p>You should use:</p> <pre><code>$password = hash('sha256',$_POST['password']); </code></pre> <p>And store that string, or any other hash variant you prefer - sha256 happens to be the one I like to use. When a user tries to login you should again hash the password they've provided and check it against the hash stored in your database.</p> <p>And finally some users might prefer you use SSL encryption for your domain if they are entering passwords online, again just do a google search if you are unfamiliar, any more questions I'll answer as best I can :)</p>
    singulars
    1. This table or related slice is empty.
    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