Introduction
The following steps are required to design a registration form (Sign Up Form): Step 1: Firstly, install a virtual server on your computer (eg Xampp, Wamp). Xampp is a free and open-source cross-platform web server solution stack package developed by Apache Friends, consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts written in the PHP and Perl programming languages. XAMPP stands for Cross-Platform (X), Apache (A), MySQL (M), PHP (P), and Perl (P).
Figure: Xampp Server
Figure: Notepad ++
Figure: Download Notepad ++
Step 4: Open the Notepad++ text editor and write the HTML code for designing the HTML Sign Up page.\
We will use various HTML tags to design the page. You can include the fields according to your convenience (i.e whichever fields you require for the form). Here I have included the fields according to my convenience. Have a view of the code written in notepad++,
- <html>
- <head>
- <title>Registration Form</title>
- </head>
- <body>
- <link href = "registration.css" type = "text/css" rel = "stylesheet" />
- <h2>Sign Up</h2>
- <form name = "form1" action="modified.php" method = "post" enctype = "multipart/form-data" >
- <div class = "container">
- <div class = "form_group">
- <label>First Name:</label>
- <input type = "text" name = "fname" value = "" required/>
- </div>
- <div class = "form_group">
- <label>Middle Name:</label>
- <input type = "text" name = "mname" value = "" required />
- </div>
- <div class = "form_group">
- <label>Last Name:</label>
- <input type = "text" name = "lname" value = "" required/>
- </div>
- <div class = "form_group">
- <label>Password:</label>
- <input type = "password" name = "pwd" value = "" required/>
- </div>
- </div>
- </form>
- </body>
- </html>
Here I have included the LINK tag to link the CSS file for this HTML page. HTML or Hypertext Markup Language is the standard and most basic language in use to create web pages. CSS stands for Cascading Style Sheets This is used for styling purpose. HTML coding is just a structure and CSS is applied to dictate your website's look and feel. Font size, font color, font style styling of images, page layout, mouse-over effects and more are determined by CSS. The CSS applied over the above HTML coding is given below.
- .container {
- max-width: 1350px;
- width: 100%;
- margin: 50px;
- height: auto;
- display: block;
- }
- body {
- color: #8A2BE2;
- font-size: 20px;
- font-family: Verdana, Arial, Helvetica, monospace;
- background-color: #F0E8A0;
- }
- h2 {
- text-align: center;
- }
- .form_group {
- padding: 10px;
- ;
- display: block;
- }
- label {
- float: left;
- padding-right: 50px;
- line-height: 10%;
- display: block;
- width: 208px;
- }
We use dot(.) beside any class to apply effects into it and ‘#’ tag before any ID. E.g. .container {
// css attributes will be written hereNote: Save the Sign_Up page in the xampp folder->htdocs->create a new folder( user-defined). Inside this new folder, you have to keep all the data related to your project. It may be any kind of images used in webpage, HTML coding, or CSS coding. I mean to say all the things that are used in creating a web page must be under one roof (i.e under one folder).
Figure: Sign_Up
After writing the HTML code and applying the above CSS, the registration page would look like above. Next, we will insert data into the fields of the sign_up page and store the information in MySQL. For that, we have to start the xampp controller. Start Apache and MYSQL in the XAMPP controller. Now we will go to the next level where we will make use of PHP syntax. PHP PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. PHP is an acronym for "PHP: Hypertext Preprocessor".
Figure: Xammp Start
- A variable starts with the $ sign, followed by the name of the variable.
- A variable name must start with a letter or the underscore character.
- A variable name cannot start with a number.
- Variable names are case-sensitive ($age and $AGE are two different variables).
PHP FORMS
Write Html coding for sign_up page and save it as index.php. Again create a PHP page named connection.php where we will write the code for creating a connection with the database.
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $conn = mysql_connect ($servername , $username , $password) or die("unable to connect to host");
- $sql = mysql_select_db ('test',$conn) or die("unable to connect to database");
- ?>
Figure: phpmyadmin
Figure: Insert fields
Figure: Structure
- GET Method: The GET method produces a long string that appears in the browser's location. It has a restriction of sending up to 1024 characters only. We should never use the GET method if we have a password or other sensitive information to be sent to the server. The PHP provides $_GET associative array to access all the information sent using the GET method.
- POST Method: In this method, parameters are not saved in browser history. Data is not shown in the browser's URL. POST is safer than GET. The PHP provides $_POST associative array to access all the information sent using the POST method.
- <?php
- include "connection.php";
- if(isset($_GET['id'])){
- $sql = "delete from registration where id = '".$_GET['id']."'";
- $result = mysql_query($sql);
- }
- $sql = "select * from registration";
- $result = mysql_query($sql);
- ?>
- <html>
- <body>
- <table width = "100%" border = "1" cellspacing = "1" cellpadding = "1">
- <tr>
- <td>Id</td>
- <td>First Name</td>
- <td>Middle Name</td>
- <td>Last Name</td>
- <td>Password</td>
- <td>Confirm Password</td>
- <td>Email</td>
- <td>Contact No.</td>
- <td>Gender</td>
- <td>Address</td>
- <td>Pincode</td>
- <td>City</td>
- <td>Country</td>
- <td>Skills</td>
- <td>Files</td>
- <td colspan = "2">Action</td>
- </tr>
- </table>
- </body>
- </html>
- <?php
- while($row = mysql_fetch_object($result)){
- ?>
- <tr>
- <td>
- <?php echo $row->id;?>
- </td>
- <td>
- <?php echo $row->fname;?>
- </td>
- <td>
- <?php echo $row->mname;?>
- </td>
- <td>
- <?php echo $row->lname;?>
- </td>
- <td>
- <?php echo $row->pwd;?>
- </td>
- <td>
- <?php echo $row->cnf;?>
- </td>
- <td>
- <?php echo $row->mail;?>
- </td>
- <td>
- <?php echo $row->number;?>
- </td>
- <td>G
- <?php echo $row->sex;?>
- </td>
- <td>
- <?php echo $row->address;?>
- </td>
- <td>
- <?php echo $row->code;?>
- </td>
- <td>
- <?php echo $row->city;?>
- </td>
- <td>
- <?php echo $row->country;?>
- </td>
- <td>
- <?php echo $row->skills;?>
- </td>
- <td>
- <?php echo $row->attach_file;?>
- </td>
- <td> <a href="listing.php?id =
- <?php echo $row->id;?>" onclick="return confirm('Are You Sure')">Delete
- </a> | <a href="index.php?id =
- <?php echo $row->id;?>" onclick="return confirm('Are You Sure')">Edit
- </a> </td>
- <tr>
- <? php } ?>
Figure: Final View
0 Comments