<?php
if(isset($_POST['button']))
{
$name=$_POST['name'];
$address=$_POST['address'];
$user_name=$_POST['user_name'];
$pass=$_POST['pass'];
//echo "$name $address $user_name $pass";
if (mysql_connect("localhost","root",""))
{
//echo "connected";
mysql_select_db("php_classes");
$query1="select user_id from profile where user_name=\"$user_name\"";
$result1=mysql_query($query1);
if(mysql_num_rows($result1)>0)
{
echo "This username is not available";
}
else
{
$query="insert into profile(name,address,user_name,pass,added_on) values ('$name','$address','$user_name',MD5('$pass'),NOW())";
//echo $query;
$result=mysql_query($query);
if (mysql_affected_rows()==1)
{
echo "You Are registered";
}
else
{
echo "You Are NOT registered";
}
}
}
else
{
echo "Could not connect to database";
}
}//end of submit
?>
<form id="form1" name="form1" method="post" action="register.php">
<p>Name
<label>
<input type="text" name="name" id="name" />
</label>
</p>
<p>Address
<input type="text" name="address" id="address" />
</p>
<p>Username
<input type="text" name="user_name" id="user_name" />
</p>
<p>Password
<input type="password" name="pass" id="pass" />
</p>
<p>
<input type="submit" name="button" id="button" value="Submit" />
</p>
</form>
<?php
/*
mysql_connect()//connects
mysql_select_db()//
mysql_query()//passes query to mysql from php/
//CUD-Create-Unpdate-Delete---
//R-Read
mysql_affected_rows
mysql_num_rows
mysql_fetch_array
*/
?>
insert in the database, insert in the mysql database, insert in the php and mysql database, insert in the database using the php code
No comments:
Post a Comment