Can't get information to load into mysql database.
Posted by: qfmarine (---.hsd1.ca.comcast.net)
Date: July 29, 2018 07:21PM

<?php
session_start();
if(isset($_SESSION['userSession'])!=""winking smiley
{
header("Location: home.php"winking smiley;
}
include("dbconnect.php"winking smiley;

if(isset($_POST['btn-signup']))
{
$uname = $MySQLi_CON->real_escape_string(trim($_POST['user_name']));
$email = $MySQLi_CON->real_escape_string(trim($_POST['user_email']));
$upass = $MySQLi_CON->real_escape_string(trim($_POST['password']));

$new_password = password_hash($upass, PASSWORD_DEFAULT);

$check_email = $MySQLi_CON->query("SELECT email FROM users WHERE email='$email'"winking smiley;
$count=$check_email->num_rows;

$RandomKey = mt_rand(1,50);
$RegKey = hash_hmac('sha512', $value, $RandomKey);
$Status = 'online';
$Banned = 'no';


if($count==0){



$query = "INSERT INTO users(username,email,password,regkey,status,banned) VALUES('$uname','$email','$new_password','$RegKey','$Status','$Banned')";


if($MySQLi_CON->query($query))
{
$msg = "<div class='alert alert-success'>
<span class='glyphicon glyphicon-info-sign'></span> &nbsp; successfully registered !
</div>";


}
else
{
$msg = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> &nbsp; error while registering !
</div>";
}
}
else{


$msg = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> &nbsp; sorry email already taken !
</div>";

}

$MySQLi_CON->close();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[www.w3.org];
<html xmlns="[www.w3.org];
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Wazza : Login & Registration System</title>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
<link rel="stylesheet" href="style.css" type="text/css" />

</head>
<body>

<div class="signin-form">

<div class="container">


<form class="form-signin" method="post" id="register-form">

<h2 class="form-signin-heading">Sign Up</h2><hr />

<?php
if(isset($msg)){
echo $msg;
}
else{
?>
<div class='alert alert-info'>
<span class='glyphicon glyphicon-asterisk'></span> &nbsp; all the fields are mandatory !
</div>
<?php
}
?>

<div class="form-group">
<input type="text" class="form-control" placeholder="Username" name="user_name" required />
</div>

<div class="form-group">
<input type="email" class="form-control" placeholder="Email address" name="user_email" required />
<span id="check-e"></span>
</div>

<div class="form-group">
<input type="password" class="form-control" placeholder="Password" name="password" required />
</div>

<hr />

<div class="form-group">
<button type="submit" class="btn btn-default" name="btn-signup">
<span class="glyphicon glyphicon-log-in"></span> &nbsp; Create Account
</button>

<a href="index.php" class="btn btn-default" style="float:right;">Log In Here</a>

</div>

</form>

</div>

</div>

</body>
</html>



This is a registration form but when I try and register a new user it always throws the error "error while registering". I am stumped on this one. Any help would be greatly appreciated.

Options: ReplyQuote
Re: Can't get information to load into mysql database.
Posted by: RiggsFolly (Moderator)
Date: July 30, 2018 01:33AM

Hi,

This is not a PHP issue sire. We deal with WAMPServer issues only and this is not that.

I would say one thing though. You are usingthe `mysql_` database extensio, so if you are using PHP 7 or greater as well this will no longer work as that extension was remove forever in php7.

Have you looked in the php error log?

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote


Sorry, only registered users may post in this forum.