Re: insert to table in php scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Consistently

here is the code:
<?php
session_start();
$connection=Mysql_connect('localhost','admin','123');
Mysql_select_db('db',$connection);
if(array_key_exists('sub',$_POST)&&$_POST['sub']=='Register')
{
$str=$_POST['uname'];
$str2=$_POST['pass1'];
$str3=$_POST['pname'];
$str4=$_POST['lname'];

$query="select * from user where user='$str'";
$result=mysql_query($query);
if (!$result)
{
print(mysql_errno() .":". mysql_error());
}

$num=Mysql_num_rows($result);

if($num==0)
{
$query1="insert into
user(kind,user,pass,name)values('p','$str','$str2','$str3')";
$result1=mysql_query($query1);

if (!$result1)
{
print(mysql_errno() .":". mysql_error());
}

$query2="insert into pnt(name,lname)values('$str3','$str4')";
$result2=mysql_query($query2);

if (!$result2)
{
print(mysql_errno() .":". mysql_error());
}

echo "you have been registered successfully!";
}
else
echo"sorry this account was used";
}
?>
<html>

<head>
<title>Registration</title>
</head>
<body>
<form method="post">
<fieldset><legend><b>Complete the form below:</b></legend>
 <p><b>Name:</b><input type="text" name="pname" />
<p><b>Last name:</b><input type="text" name="lname" />
<p><b>Username:</b><input type="text" name="uname" />
<p><b>Password:</b><input type="password" name="pass1" />
 </fieldset>
<input type="submit" name='sub' value="Register"/>
</form>
</body>
</html>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux