Firstly, you're mixing MySQL libraries with mysqli_num_rows
use mysql_num_rows
.
- Those different MySQL functions do not intermix with each other.
You also need to start the session if you haven't already.
Make sure also that your form elements contain name attributes.
I.e.: <input type="text" name="username">
etc.
Then this line:
mysql_query($sql,$con);
if(mysqli_num_rows($run)>0){
that should read as
$run = mysql_query($sql,$con);
if(mysql_num_rows($run)>0){
You may also change
$run = mysql_query($sql,$con);
to
$run = mysql_query($sql,$con) or die(mysql_error($con));
- In order to see if your query failed.
I noticed you may be storing passwords in plain text. If this is the case, it is highly discouraged.
I recommend you use CRYPT_BLOWFISH or PHP 5.5's password_hash()
function. For PHP < 5.5 use the password_hash() compatibility pack
.
Plus, in regards to SQL injection, use mysqli
with prepared statements, or PDO with prepared statements, they're much safer.
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Error reporting should only be done in staging, and never production.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…