PHP and mySQL connection string
Posted: Thu Apr 10, 2014 8:05 am
Hi Guys I'm in the middle of creating my own website and I'm having trouble with letting users to register I have created the code but when I click on the "submit" button I'm getting a blank white screen
config.php
and this is the submit_form.php
Hope someone can help me and give me some pointers please
Rich
config.php
Code: Select all
<?php
//Mysql Connect | mysql_connect("host= 3306","username","");
//Below example to connect in localhost
$a=mysql_connect("localhost","root","");
//select your database
$b=mysql_select_db("database_name",$a);
?>Code: Select all
<?php
$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>';
}
?>Rich