<?php
define('DB_HOST', 'localhost');
define('DB_NAME', 'tumy'); [tumy is the database name]
define('DB_USER','root');
define('DB_PASSWORD','');
$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());
function newUser()
{
$username = $_POST['username'];
$password = $_POST['password'];
$name = $_POST['name'];
$telNo = $_POST['telno']; [telno refers to telephone number]
$emailAddress = $_POST['email'];
$query = "INSERT INTO 'customer' (username,password,name,telNo,emailAddress) VALUES ('$username','$password','$name','$telNo','$emailAddress')";
$data = mysql_query($query) or die(mysql_error());
if($data) {
echo "YOUR REGISTRATION IS COMPLETED";
}
}
function SignUp()
{
if(empty($_POST['uname']))
{
$query = mysql_query("SELECT * FROM customer WHERE username = '$_POST[username]' AND password = '$_POST[password]'") or die(mysql_error());
if(!$row = mysql_fetch_array($query) or die("SORRY.YOU ARE ALREADY REGISTERED USER.".mysql_error()))
{
newUser();
}
}
}
if(isset($_POST['submit']))
{
SignUp();
}
?>
Why I already linked to my database and insert the value into the form set in php file, why it just link to this file with blank page? How should the value insert into the database? Because I already connect with define('DB_NAME','tumy'); Hope can answer this question as till now don't have any value insert into the database although I'm already key in. Thanks.