Creation Of SignUp Form Page Using OOPS Constructor Method

Creation Of SignUp Form Page Using OOPS Constructor Method

OUTPUT PAGE:

Here in my below output page I have shown that once I fill up the details and click on the "SIGN UP" button, it will show me the output as shown in the below image.


CODING:

Now just let me explain the whole code which I have executed. So, let's begin.
At first just let me explain why I have taken <div> tag? And what is <div> tag actually? So, as I know that <div> tag is basically known as division, which actually works as to divide each input field which I am taking in form. And also in <div> tag I can take a class name whose id I can use in CSS styling. 
So, as I have already talked about CSS styling, just let me explain what is CSS? and why I use CSS? Basically CSS is known as "Cascading Style Sheets". And I use CSS because of styling purpose to give the color, background, colour, to make the text bold or bolder to increase the size of the text which I have executed in my code as shown below.
<style type="text/css">
.b1{
text-align: center;
background-color: blue;
color: yellow;
}
.b2{
text-align: center;
}
.b3{
background-color: lightseagreen;
color: darkred;
font-size: 20px;
font-weight: bolder;
text-align: center;
}
.b4{
color: darkgreen;
font-weight: bolder;
background-color: yellow;
}
</style>

Now let me explain what is <h1> tag? Basically first about <h1> tag I need to know how many <h> tags are basically their. Basically, as per I know, we have 6 <h> tags, starting from <h1> tag to <h6> tag. Now directly coming to what is <h1> tag? So, <h1> tag is basically a heading tag. And why it is mentioned as <h1> tag, <h2> tag, <h3> tag, <h4> tag, <h5> tag, <h6> tag? Because each heading tag has each and individual size. Where <h1> tag is the most largest size and <h6> tag is the most smallest size.
Now let me explain why I have used the image url inside <img> tag? I have used the image url inside <img> tag as because to display the image itself. And if I don't provide the image url inside <img> tag then I will not able to see the image, I can only see the image url. And I have used the height and width inside <img> tag to set the size of the image.
Now let me explain why I have taken form? I have taken form basically for collecting the user input means the input fields which I am providing inside my form. And Form also helps to input the fields which the user wants and to click on the submit button to sent the request directly to the server.
Now let me explain why I have used method as post inside my form? I have used method as post inside my form as because post method is the most secure method and post method doesn't pass query string. So, now you may ask me can't I use get method? Yes, obviously, you can use get method but generally we don't. Because get method is not the secure method as well as it passes query string.
Now just let me explain why I have used isset() function in my if condition. I have used isset() function as because isset() function is used to set the variable, which means the variable should exists and it should not be NULL. isset() function basically sents TRUE if the variable exists and is not NULL> otherwise it sents FALSE.
Now let me explain what is __construct() function? so, __ construct() function is the magic keyword where double underscore(__) is required.


FULL CODE:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>SignUp Form</title>

<style type="text/css">

.b1{

text-align: center;

background-color: blue;

color: yellow;

}

.b2{

text-align: center;

}

.b3{

background-color: lightseagreen;

color: darkred;

font-size: 20px;

font-weight: bolder;

text-align: center;

}

.b4{

color: darkgreen;

font-weight: bolder;

background-color: yellow;

}

</style>

</head>

<body>

<div class="b1">

<h1>SIGN UP</h1>

</div>

<div class="b2">

<img src="https://st3.depositphotos.com/15648834/17930/v/450/depositphotos_179308454-stock-illustration-unknown-person-silhouette-glasses-profile.jpg" height="150px" width="150px">

</div>

<form method="post">

<div class="b3">

Username <br> <input type="text" name="username"><br>

Email <br> <input type="email" name="email"><br>

Password <br> <input type="password" name="password"><br>

<button type="submit" name="submit" value="submit" class="b4">SIGN UP</button><br>

</div>

</form>

<?php

if (isset($_REQUEST['submit'])) {

$username=$_REQUEST['username'];

$email=$_REQUEST['email'];

$password=$_REQUEST['password'];

class Signup

{

function __construct($username,$email,$password)

{

$this->un=$username;

$this->em=$email;

$this->pa=$password;

}

function display()

{

echo $this->un."<br>".$this->em."<br>".$this->pa;

}

}

$obj=new Signup($username,$email,$password);

$obj->display();

}

?>

</body>

</html>


Comments

Popular posts from this blog

Programmings Based On Array And String Functions To Merge The 2 Arrays, Then After Merge Convert Into String And Then Find Out The 1st And Last Word From The Reverse String

PHP WEB DEVELOPMENT INTERVIEW QUESTIONS ASKED IN APOLLO HOSPITAL ALONG WITH MY OWN CONCEPTS AND MY OWN EXPLANATION ANSWERS(PART - 1) REST OF THE QUESTIONS AND ANSWERS WILL BE PREPARED BY ME IN MY NEXT BLOG

Mini Project On Multi User CRUD Operations(Create, Read, Update & Delete) Of Donar Details Of Indian Nationals Who Donate To Ramkrishna Math, Belur Math Using PDO (PHP Data Objects) With Proper Explanation Of Each And Every Individual Line Of The Code Of connection.php Page, form.php Page, formaction.php Page, admin_display.php Page, client_display.php Page, edit.php Page, editaction.php Page And delet.php Page (Here You Will Find The Image Of Sayang Sri Ramkrishna Dev, Sayang Sri Ma Sarada Devi & Sayang Sri Swami Vivekananda) In My CRUD Operation