I made this funny script but in my registration data database apear balnk. when I repeat to enter another data database give me a duplicate key. I plz can anyone amend this?
CREATE DATABASE bahala;
CREATE TABLE users (
username varchar(30) NOT NULL,
password varchar(30) NOT NULL,
emailvarchar(40) NOT NULL,
primary key(username));
config.php
<?php
class MySQLDB {
private $DB_SERVER;
private $DB_USER;
private $DB_PASS;
private $DB_NAME;
private $username;
private $password;
private $password2;
private $email;
public function db_connect($DB_SERVER, $DB_USER, $DB_PASS){
$this->DB_SERVER = "localhost";
$this->DB_USER = "root";
$this->DB_PASS = "";
return mysql_connect($this->DB_SERVER, $this->DB_USER, $this->DB_PASS) or die('Can not connect to BHL, try again' . mysql_error());
}
public function DB_NAME($DB_NAME){
$this->DB_NAME = "bahala";
return mysql_select_db($this->DB_NAME) or die(mysql_error());
}
public function registerUser($username, $password, $password2, $email){
$this->username = $_POST['username'];
$this->password = $_POST['password'];
$this->password2 = $_POST['password2'];
$this->email = $_POST['email'];
$query = "INSERT INTO users VALUES ('$username', '$password', '$email')";
$result = @mysql_query($query) or die(mysql_error());
if (!$result){
die("nooooo" . mysql_error());
}
}
}
$DATABASE = new MySQLDB();
$DATABASE->db_connect($DB_SERVER, $DB_USER, $DB_PASS);
$DATABASE->DB_NAME($DB_NAME);
$DATABASE->registerUser($username, $password, $password2, $email);
?>
register.php
<?php
include ("config.php");
include ("regform.html");
?>Ooooh I think I missed something. It should be like that. now everything is ok.
$query = "INSERT INTO users VALUES ('{$this->username}', '{$this->password}', '{$this->email}')";
$result = @mysql_query($query) or die(mysql_error());
if (!$result){
die("nooooo" . mysql_error());
}
plz can anyone help me to develope this funny script?
CREATE DATABASE bahala;
CREATE TABLE users (
username varchar(30) NOT NULL,
password varchar(30) NOT NULL,
emailvarchar(40) NOT NULL,
primary key(username));
config.php
<?php
class MySQLDB {
private $DB_SERVER;
private $DB_USER;
private $DB_PASS;
private $DB_NAME;
private $username;
private $password;
private $password2;
private $email;
public function db_connect($DB_SERVER, $DB_USER, $DB_PASS){
$this->DB_SERVER = "localhost";
$this->DB_USER = "root";
$this->DB_PASS = "";
return mysql_connect($this->DB_SERVER, $this->DB_USER, $this->DB_PASS) or die('Can not connect to BHL, try again' . mysql_error());
}
public function DB_NAME($DB_NAME){
$this->DB_NAME = "bahala";
return mysql_select_db($this->DB_NAME) or die(mysql_error());
}
public function registerUser($username, $password, $password2, $email){
$this->username = $_POST['username'];
$this->password = $_POST['password'];
$this->password2 = $_POST['password2'];
$this->email = $_POST['email'];
$query = "INSERT INTO users VALUES ('$username', '$password', '$email')";
$result = @mysql_query($query) or die(mysql_error());
if (!$result){
die("nooooo" . mysql_error());
}
}
}
$DATABASE = new MySQLDB();
$DATABASE->db_connect($DB_SERVER, $DB_USER, $DB_PASS);
$DATABASE->DB_NAME($DB_NAME);
$DATABASE->registerUser($username, $password, $password2, $email);
?>
register.php
<?php
include ("config.php");
include ("regform.html");
?>Ooooh I think I missed something. It should be like that. now everything is ok.
$query = "INSERT INTO users VALUES ('{$this->username}', '{$this->password}', '{$this->email}')";
$result = @mysql_query($query) or die(mysql_error());
if (!$result){
die("nooooo" . mysql_error());
}
plz can anyone help me to develope this funny script?