Wednesday, 18 January 2012

simple registration form


for form :
<html>
<body>
<h1> Registration Form : </h1>
<form name="form1" action="register.php" method="post" />
Name :
   <input type="text" name="name" value=""/>

Address :
  <input type="text" name="address" value=""/>
  <input type="submit" name="submit" value="Register"/>
  </form>

</body>
</html>

register.php


?php
include("cls.php");
$obj= new connect();
$obj->connect();

$varname=$_POST['name'];
$varaddress=$_POST['address'];

$sqlinsert= "insert into reg(name,address)values('$varname','$varaddress')";
if(!mysql_query($sqlinsert))
{
echo "errro in querry".mysql_error();
}
else
{
echo"registration complete";
}
?>


cls.php



<?php
class connect
{
function connect()
{
$con = mysql_connect('localhost','root','');
if(!$con)
{
die("Error in database connection");
}
$sdb=mysql_select_db('db',$con);
if(!$sdb)
{
die("Erroe in database selection");
}

}
}
?>









No comments:

Post a Comment