Forms action page

Lets make our first form page which will be used for registration in your site.

Username : First Name : Second Name :

The user inputs the values and handle them as per our wish. Once, the user submits the form, all the values are available to the action file mentioned at the beginning of the form.So, lets see what we can do in register.php file

$userName = mysql_real_escape_string($_GET['userName']);
$firName = mysql_real_escape_string($_GET['firName']);
$secName = mysql_real_escape_string($_GET['secName']);	
// connecting to mysql
$con = mysql_connect("yourServerName","userName","passWord")or die("Cannot connect to mysql");
// selecting database
mysql_select_db("regDB", $con);
$search_q = "select * from regTable where userName='$userName'";
$ans_q = mysql_query($search_q);
$cnt = mysql_num_rows($ans_q);
if ($cnt==0){
mysql_query("INSERT INTO regTable (FirstName, LastName, userName) 
VALUES ('$firName', '$secName', '$userName')");
else {
echo "Duplicate userNAme. Try to have a different username.";

Thats all for the PHP form. Lets see some other important data storing arrays of PHP i.e. Session and Cookie variable.

Member Login

Member Login

Not a Member? Sign Up!

Login to comment

Be the first to comment on this topic


<<< Wanna review

Continue >>>