I am going to create a register page to do the homework,and i can't found that simple answer of it.Here is the problem. i want to insert the new loginid and password in the a table call customerlist and create the new table named of the new loginid.
Here is the code:
$loginid = $_POST['loginid'];
$pw = $_POST['pw'];
$pw2 = $_POST['pw2'];
if($loginid != null && $pw != null && $pw2 != null && $pw == $pw2)
{ $sql = "insert into 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 into customerlist(LoginID,Password,Name,Phone,IDCARDNO,Email,BankACNO,Plan,Date) values ('$loginid','$pw','$name','$telephone','$idcard','$email','bankac','plan','date')";
$sql2 = "insert into 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, but why the result is fail??? whats wrong of it?