Hi Guys as I have mentioned before I'm having problems with connecting my website to a sql database,
config.php
<?php
ini_set('display_errors', true); // change to false when you go live
error_reporting(E_ALL);
//Mysql Connect | mysql_connect("host= 3306","username","");
//Below example to connect in localhost
//$a=mysql_connect("localhost","root","");
if($a == false) {
die("Connect failed: ".mysql_error());
}
//select your database
$b=mysql_select_db("database_name",$a);
if($b == false) {
die("DB select failed: ".mysql_error());
}
?>
submit_form.php
<?php
//select your database
//$b=mysql_select_db("database_name",$a);
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$username=$_POST['username'];
//$confirmusername=$_POST['confirmusername'];
$password=$_POST['password'];
$confirmpassword=$_POST['confirmpassword'];
$email=$_POST['email'];
$confirmemail=$_POST['confirmemail'];
//Database connection
require_once("config.php");
//mysql query to insert value to database
$query=mysql_query("INSERT INTO registration (`firstname`, `lastname`, `username`, `confirmusername`, `password`, `confirmpassword`, `email` ,`confirmemail`) VALUES ('$firstname', '$lastname', '$username', '$password', '$confirmpassword', '$email' , '$confirmemail')");
//if value inserted successyully disply success message
if($query)
{
echo 'Registred successfully..!!</div>';
}else
{
//error message
echo '<unable to registred !!</div>';
}
?>
I have done a few changes and now I'm getting this error message, at least it looks more prommising than a week ago where I was getting just a full blank white page
Notice: Undefined variable: a in C:\xampp\htdocs\config.php on line 9
Connect failed: