login - (update) php of create two things at the same time of register? -



login - (update) php of create two things at the same time of register? -

i going create register page homework,and can't found simple reply of it.here problem. want insert new loginid , password in table phone call customerlist , create new table named of new loginid.

here code:

$loginid = $_post['loginid']; $pw = $_post['pw']; $pw2 = $_post['pw2']; if($loginid != null && $pw != null && $pw2 != null && $pw == $pw2) { $sql = "insert customerlist(loginid,password) values ('$loginid','$pw')"; $sql="create table {$loginid} ( tradeid(50) varchar(20), trademode varchar(10), tradedate data, mtrdate varchar(50) , postaddress varchar(255), tel varchar(15), receivables int, status varchar(10) );"; if(mysql_query($sql)) { echo 'success!'; echo '<meta http-equiv=refresh content=2;url=index.php>'; } else { echo 'fail!'; echo '<meta http-equiv=refresh content=2;url=index.php>'; } } else { echo 'get out!'; echo '<meta http-equiv=refresh content=2;url=index.php>'; } ?>

update

<?php $con = mysql_connect("localhost","root","password"); mysql_select_db("babytradeapps"); $loginid = $_post['loginid']; $pw = $_post['pw']; $pw2 = $_post['pw2']; $name = $_post['name']; $telephone = $_post['telephone']; $idcard = $_post['idcard']; $email = $_post['email']; $bankac = $_post['bankac']; $plan = $_post['plan']; $date = $_post['date']; if($loginid != null && $pw != null && $pw2 != null && $pw == $pw2) { $sql = "insert customerlist(loginid,password,name,phone,idcardno,email,bankacno,plan,date) values ('$loginid','$pw','$name','$telephone','$idcard','$email','bankac','plan','date')"; $sql2 = "insert overall(loginid,tradeid,trademode,tradedate,mtrdate,postaddress,tel,receivables,status) values ('$loginid','example','example','example','example','example','example','example','example')"; if(mysql_query($sql)&& mysql_query($sql2)) { echo 'success!'; echo '<meta http-equiv=refresh content=2;url=index.php>'; } else { echo 'fail!'; echo '<meta http-equiv=refresh content=2;url=index.php>'; } } else { echo 'get out!'; echo '<meta http-equiv=refresh content=2;url=index.php>'; } ?>

i have changed, why result fail??? whats wrong of it?

you overwriting $sql variable insert statement right in next line create table statement, sec command executed. utilize different variable , create 2 queries.

$sql = "insert customerlist(loginid,password) values ('$loginid','$pw')"; $sql2="create table {$loginid} ( tradeid(50) varchar(20), trademode varchar(10), tradedate data, mtrdate varchar(50) , postaddress varchar(255), tel varchar(15), receivables int, status varchar(10) );"; if(mysql_query($sql) && mysql_query($sql2))

also heed warning of zerkms, creating many tables not database layout.

another note: using mysql_* functions becoming deprecated , removed future versions of php. utilize mysqli_* or pdo instead.

php login

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -