Im fairly new to php/sql, but I did alot of research about this until I decided to get help.
Basically im trying to insert a new username/email/password/salt into a MySQL5 DB. This is my test register.php with just an echo:
include 'dbcxn.php';
$usr = $_POST['user'];
$mail = $_POST['mail'];
$pwd = $_POST['p'];
$random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
$password = hash('sha512', $pwd.$random_salt);
$insert_stmt = DB::cxn()->prepare("INSERT INTO members (username, email, password, salt) VALUES ($usr, $mail, $password, $random_salt)");
echo $insert_stmt->param_count." parameters\n";
I tried using just "$insert_stmt = $mysqli->prepare", same thing happens. So I made the class DB. Here's my dbcxn.php if it helps:
define("HOST", "");
define("USER", "");
define("PASSWORD", "");
define("DATABASE", "");
define("PORT", "");
$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE, PORT);
class DB {
private static $mysqls;
private function __construct(){}
static function cxn() {
if( !self::$mysqls ) {
self::$mysqls = new mysqli(HOST, USER, PASSWORD, DATABASE, PORT);
}
return self::$mysqls;
}
}
Don't know what else to try and need to get some sleep :). Thanks in advance for any advice.