I've been stuck for a couple days connecting the registration looking through forums etc. No error seems to populate on the page, but when I take a look at phpMyAdmin it doesn't show the registration info inserted in the db.
register.php
<?php
session_start();
if(isset($_SESSION['user'])!="")
{
header("Location: home.php");
}
$servername = "correctly inserted info";
$username = "correctly inserted info";
$password = "correctly inserted info";
$dbname = "correctly inserted info";
$conn = new mysqli($servername, $username, $password, $dbname);
if(isset($_POST['btn-signup']))
{
$fname = mysql_real_escape_string($_POST['fullname']);
$uname = mysql_real_escape_string($_POST['username']);
$email = mysql_real_escape_string($_POST['email']);
$upass = md5(mysql_real_escape_string($_POST['password']));
if(mysql_query("INSERT INTO users(fullname,username,email,password) VALUES('$fname','$uname','$email','$upass')"))
{
?>
<script>alert('successfully registered');</script>
<?php
}
else
{
?>
<script>alert('error while registering you...');</script>
<?php
}
}
?>
registration.php
<!DOCTYPE html>
<!--[if IE 9 ]><html class="ie9"><![endif]-->
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<meta name="format-detection" content="telephone=no">
<meta charset="UTF-8">
<meta name="description" content="Violate Responsive Admin Template">
<meta name="keywords" content="Super Admin, Admin, Template, Bootstrap">
<title>Super Admin Responsive Template</title>
<!-- CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/form.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/generics.css" rel="stylesheet">
</head>
<body id="skin-blur-violate">
<section id="login">
<header>
<h1>SUPER ADMIN</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eu risus. Curabitur commodo lorem fringilla enim feugiat commodo sed ac lacus.</p>
</header>
<div class="clearfix"></div>
<!-- Login -->
<form class="box tile animated active" id="box-login">
<!-- Register -->
<?php require_once("register.php"); ?>
<form class="box animated tile" id="box-register" method="post">
<h2 class="m-t-0 m-b-15">Register</h2>
<input type="text" class="login-control m-b-10" placeholder="Full Name" name="fname" required/>
<input type="text" class="login-control m-b-10" placeholder="Username" name="uname" required/>
<input type="email" class="login-control m-b-10" placeholder="Email Address" name="email" required/>
<input type="password" class="login-control m-b-10" placeholder="Password" name="pass" required/>
<button class="btn btn-sm m-r-5" type="submit">Register</button>
<small><a class="box-switcher" data-switch="box-login" href="">Already have an Account?</a></small>
</form>
<!-- Forgot Password -->
</section>
<!-- Javascript Libraries -->
<!-- jQuery -->
<script src="js/jquery.min.js"></script> <!-- jQuery Library -->
<!-- Bootstrap -->
<script src="js/bootstrap.min.js"></script>
<!-- Form Related -->
<script src="js/icheck.js"></script> <!-- Custom Checkbox + Radio - ->
<!-- All JS functions -->
<script src="js/functions.js"></script>
</body>
</html>
I've editing the code to help cause I'm still coming up with the same issue, but many seem to be on the right track. I was using mysql and mysqli interchangeably. I looking in my dbconnect.php file and found the following which looks like I'll also need to change to make it uniform with the mysqli being displayed in other areas. On the right track, but not there yet.
I just found though that dbconnect.php is deploying the mysql version and not the mysql version any thoughts?
I just found though that dbconnect.php is deploying the mysql version and not the mysql version any thoughts?
dbconnect.php
<?php
if(!mysql_connect("correct host","correct username","correct password"))
{
die('oops connection problem ! --> '.mysql_error());
}
if(!mysql_select_db("correct db"))
{
die('oops database selection problem ! --> '.mysql_error());
}
?>
Based on the starting responses I found that many we're helping me get on the right track...here are the other correlating files since the general theme is I am interchanging mysql and mysqli. Parts of it seemed to work initially but now it's all coming apart so if anyone can help me put it all back together again appreciate it. I'm still having no response from posting to the database which is why I'm making the edits.
index.php
<?php
session_start();
include_once 'dbconnect.php';
if(isset($_SESSION['user'])!="")
{
header("Location: home.php");
}
if(isset($_POST['btn-login']))
{
$email = mysql_real_escape_string($_POST['email']);
$upass = mysql_real_escape_string($_POST['pass']);
$res=mysql_query("SELECT * FROM users WHERE email='$email'");
$row=mysql_fetch_array($res);
if($row['password']==md5($upass))
{
$_SESSION['user'] = $row['user_id'];
header("Location: home.php");
}
else
{
?>
<script>alert('wrong details');</script>
<?php
}
}
?>
Just so I'm showing all I have in this process....I'm also putting in my login.php file so hopefully I can get this all resolved.
login.php
<!DOCTYPE html>
<!--[if IE 9 ]><html class="ie9"><![endif]-->
<head>
<meta name="viewport" content="width=device-width, initial- scale=1.0, maximum-scale=1.0" />
<meta name="format-detection" content="telephone=no">
<meta charset="UTF-8">
<meta name="description" content="Violate Responsive Admin Template">
<meta name="keywords" content="Super Admin, Admin, Template, Bootstrap">
<title>Super Admin Responsive Template</title>
<!-- CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/form.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/generics.css" rel="stylesheet">
</head>
<body id="skin-blur-violate">
<section id="login">
<header>
<h1>SUPER ADMIN</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eu risus. Curabitur commodo lorem fringilla enim feugiat commodo sed ac lacus.</p>
</header>
<div class="clearfix"></div>
<!-- Login -->
<?php require_once("index.php"); ?>
<form class="box tile animated active" id="box-login">
<h2 class="m-t-0 m-b-15">Login</h2>
<input type="text" class="login-control m-b-10" placeholder="Username or Email Address">
<input type="password" class="login-control" placeholder="Password">
<div class="checkbox m-b-20">
<label>
<input type="checkbox">
Remember Me
</label>
</div>
<button type="submit" name="btn-login" class="btn btn-sm m-r-5">Sign In</button>
<small>
<a href="registration.php">Don't have an Account?</a> or
<a class="box-switcher" data-switch="box-reset" href="">Forgot Password?</a>
</small>
</form>
<!-- Forgot Password -->
<form class="box animated tile" id="box-reset">
<h2 class="m-t-0 m-b-15">Reset Password</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eu risus. Curabitur commodo lorem fringilla enim feugiat commodo sed ac lacus.</p>
<input type="email" class="login-control m-b-20" placeholder="Email Address">
<button class="btn btn-sm m-r-5">Reset Password</button>
<small><a class="box-switcher" data-switch="box-login" href="">Already have an Account?</a></small>
</form>
</section>
<!-- Javascript Libraries -->
<!-- jQuery -->
<script src="js/jquery.min.js"></script> <!-- jQuery Library -->
<!-- Bootstrap -->
<script src="js/bootstrap.min.js"></script>
<!-- Form Related -->
<script src="js/icheck.js"></script> <!-- Custom Checkbox + Radio -->
<!-- All JS functions -->
<script src="js/functions.js"></script>
</body>
</html>