Vote count:
0
snippet for creating the tables $sql1="create table if not exists users( usid int(10) not null auto_increment primary key, first_name varchar(50) not null, last_name varchar(50) not null, reg_time timestamp not null default current_timestamp )DEFAULT CHARACTER SET utf8 ENGINE=InnoDB";
$sql2="create table if not exists contact(
conid int(10) not null auto_increment primary key,
email varchar(50) not null unique,
phone varchar(15) not null unique,
confk int(10) not null,
foreign key (confk) references users(usid) on delete cascade
)DEFAULT CHARACTER SET utf8 ENGINE=InnoDB";
$sql3="create table if not exists login(
logid int(10) not null auto_increment primary key,
username varchar(255) not null unique,
password varchar(255) not null,
foreign key(logid) references users(usid) on delete cascade
)DEFAULT CHARACTER SET utf8 ENGINE=InnoDB";
query to insert to the database
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$pass=$_POST['pass'];
mysql_query('BEGIN');
$sql1=mysql_query("insert into users(first_name,last_name) values ('$first_name','$last_name')");
$sql2=mysql_query("insert into contact(phone,email) values ('$phone','$email')");
$sql3=mysql_query("insert into login(username,password) values ('$phone',md5('$pass'))");
if(!$sql1 || !$sql2 || !$sql3){
@mysql_query('ROLLBACK');
echo'it didnt work!!!' . mysql_error();
}else{
@mysql_query('COMMIT');
}
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire