Facebook Twitter Instagram
    DeepCrazyWorld
    Facebook Twitter Instagram Pinterest YouTube
    • FLUTTER
      • FLUTTER APP
        • QRCode
        • Quiz App
        • Chat GPT
        • PDF App
        • News App
        • Fitness App
        • Weather App
        • BMI Calculator
        • GAME APP
        • Ecommerce App
        • wallpaper App
        • Finance app
        • Chat App
        • Wallet App
        • Taxi App
        • Quran app
        • Music player app
      • FLUTTER UI
        • Splash Screen
        • Onboarding Screen
        • Login Screen
        • Card Design
        • Drawer
    • PROJECT
      • Android Projects
      • College Projects
      • FLUTTER APP
      • Project Ideas
      • PHP Projects
      • Python Projects
    • SOURCE CODE
    • ANDROID
      • ANDROID APP
      • GAME APP
      • ANDROID STUDIO
    • MCQ
      • AKTU MCQ
        • RPA MCQ
        • COA MCQ
        • HPC MCQ
        • SPM MCQ
        • Renewable Energy All MCQ
        • Data Compression MCQ
        • Data Structure MCQ
        • Digital Image Processing MCQ
        • Software Engineering MCQ
        • Machine Learning MCQ
        • Artificial Intelligence MCQ
      • D PHARMA MCQ
        • Pharmaceutics – I MCQ
        • Pharmacognosy MCQ
        • Pharmaceutical Chemistry MCQ
        • Biochemistry and Clinical Pathology MCQ
        • Human Anatomy and Physiology MCQ
        • Heath Education and Community Pharmacy MCQ
    • INTERVIEW QUESTIONS
      • Flutter Interview Questions
      • INTERVIEW QUESTIONS
      • Python Interview Questions
      • Coding ninjas solution
    • MORE
      • WORDPRESS
        • SEO
        • TOP 10 WORDPRESS THEME
      • PRODUCTIVITY
      • Program
      • QUOTES
    DeepCrazyWorld
    Home»SOURCE CODE»PHP Registration Form with Source Code (updated)
    SOURCE CODE

    PHP Registration Form with Source Code (updated)

    DeepikaBy DeepikaNovember 27, 2021Updated:January 19, 2022No Comments7 Mins Read

    PHP Registration Form with Source Code (updated) – What do you mean by Registration Form?
    In PHP registration form is a list of fields in which a user will input data and submit it. It is useful in every situation where a registration is necessary.

    PHP (recursive acronym for PHP: Hypertext Preprocessor ) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

    For Example: Various companies use registration forms to sign up customers for services, or other programs.

    What is PHP used for? PHP is a server side scripting language that is embedded in HTML. It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites. It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server.

    <img decoding=

    In Schools and colleges a registration form is used to register students for a course in which students can fill their contact information, academic history etc.

    Table of Contents

    Toggle
    • PHP Registration form source code
    • Example 1:
    • Example 2:
    • Output:
    • Additional Reading
        • you can read more articles like this here.
    • READ MORE

    PHP Registration form source code

    Example 1:

    <! Doctype html>  
    <html lang="en">  
    <head>  
      <meta charset="utf-8">  
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">  
      <title> PHP Registration Form Example </title>  
      <style>  
    .error {   
    color: white;  
        font-family: lato;  
        background: yellowgreen;  
        display: inline-block;  
        padding: 2px 10px;  
    }  
    * {  
        padding: 0;  
        margin: 0;  
        box-sizing: border-box;  
    }  
    body {  
        margin: 50px auto;  
        text-align: center;  
        width: 800px;  
    }  
    h1 {  
        font-family: sans-serif;  
      display: block;  
      font-size: 2rem;  
      font-weight: bold;  
      text-align: center;  
      letter-spacing: 3px;  
      color: hotpink;  
        text-transform: uppercase;  
    }  
    label {  
        width: 150px;  
        display: inline-block;  
        text-align: left;  
        font-size: 1.5rem;  
        font-family: 'Lato';  
    }  
    input {  
        border: 2px solid #ccc;  
        font-size: 1.5rem;  
        font-weight: 100;  
        font-family: 'Lato';  
        padding: 10px;  
    }  
    form {  
        margin: 25px auto;  
        padding: 20px;  
        border: 5px solid #ccc;  
        width: 500px;  
        background: #f3e7e9;  
    }  
    div.form-element {  
        margin: 20px 0;  
    }  
    input[type=submit]::after {    
      background: #fff;    
      content: '';    
      position: absolute;    
      z-index: -1;    
    }    
    input[type=submit] {    
      border: 3px solid;    
      border-radius: 2px;    
      color: ;    
      display: block;    
      font-size: 1em;    
      font-weight: bold;    
      margin: 1em auto;    
      padding: 1em 4em;    
     position: relative;    
      text-transform: uppercase;    
    }    
    input[type=submit]::before   
    {    
      background: #fff;    
      content: '';    
      position: absolute;    
      z-index: -1;    
    }    
    input[type=submit]:hover {    
      color: #1A33FF;    
    }    
    </style>  
    </head>  
    <body>    
    <?php  
    $nameErr = "";  
    $emailErr = "";  
    $genderErr = "";  
    $websiteErr = "";  
    $name = "";  
    $email = "";  
    $gender = "";  
    $comment = "";  
    $website = "";  
    if ($_SERVER["REQUEST_METHOD"] == "POST") {  
      if (empty($_POST["name"])) {  
        $nameErr = "Name Field is required";  
      } else {  
        $name = test_input($_POST["name"]);  
        if (!preg_match("/^[a-zA-Z-' ]*$/",$name)) {  
          $nameErr = "Only letters and white space allowed";  
        }  
      }  
        if (empty($_POST["email"])) {  
        $emailErr = "Email field is required";  
      } else {  
        $email = test_input($_POST["email"]);  
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {  
          $emailErr = "Invalid email format";  
        }  
      }  
      if (empty($_POST["website"])) {  
        $website = "";  
      } else {  
        $website = test_input($_POST["website"]);  
        if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) {  
          $websiteErr = "Invalid URL";  
        }  
      }  
      if (empty($_POST["comment"])) {  
        $comment = "";  
      } else {  
        $comment = test_input($_POST["comment"]);  
      }  
      if (empty($_POST["gender"])) {  
        $genderErr = "Gender is required";  
      } else {  
        $gender = test_input($_POST["gender"]);  
      }  
    }  
    function test_input($data) {  
      $data = trim($data);  
      $data = stripslashes($data);  
      $data = htmlspecialchars($data);  
      return $data;  
    }  
    ?>  
    <h1> PHP Registration Form Example </h1>  
    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">    
      <b> Enter Name: </b> <input type="text" name="name" value="<?php echo $name;?>">  
      <span class="error"> *  <?php echo $nameErr;?> </span>  
      <br> <br>  
     <b> Enter E-mail: </b> <input type="text" name="email" value="<?php echo $email;?>">  
      <span class="error"> * <?php echo $emailErr;?> </span>  
      <br> <br>  
     <b> Enter Number: </b> <input type="text" name="website" value="<?php echo $website;?>">  
      <span class="error"> * <?php echo $websiteErr;?> </span>  
      <br> <br>  
      <b> Message: </b> <textarea name="comment" rows="5" cols="40"> <?php echo $comment;?> </textarea>  
      <br> <br>  
     <b> Select Gender: </b>  
      <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female"> Female  
      <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male"> Male  
      <input type="radio" name="gender" <?php if (isset($gender) && $gender=="other") echo "checked";?> value="other"> Other    
      <span class="error"> * <?php echo $genderErr;?> </span>  
      <br> <br>  
      <input type="submit" name="submit" value="Register ">    
    </form>  
    <?php  
    echo "<h2> Your Input: </h2>";  
    echo $name;  
    echo "<br>";  
    echo $email;  
    echo "<br>";  
    echo $website;  
    echo "<br>";  
    echo $comment;  
    echo "<br>";  
    echo $gender;  
    ?>  
    </body>  
    </html>  

    Explanation: In the above example, we have created a company registration form in which users filled their information required in form.

    Output: Following is the output of this example:

    <img loading=

    Example 2:

    
    <! Doctype html>  
    <html lang="en">  
    <head>  
      <meta charset="utf-8">  
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">  
      <title> PHP Registration Form </title>  
    <style>  
    input[type=radio] { width:20px; }  
    input[type=checkbox]{ width:20px; }  
    * {  
        padding: 0;  
        margin: 0;  
        box-sizing: border-box;  
    }  
    body {  
        margin: 50px auto;  
        text-align: center;  
        width: 800px;  
    }  
    input[type=reset] {  
      border: 3px solid;    
      border-radius: 2px;    
      color: ;    
      display: block;    
      font-size: 1em;    
      font-weight: bold;    
      margin: 1em auto;    
      padding: 1em 4em;    
     position: relative;    
      text-transform: uppercase;    
    }    
    input[type=reset]::before   
    {    
      background: #fff;    
      content: '';    
      position: absolute;    
      z-index: -1;    
    }    
    input[type=reset]]:hover {    
      color: #1A33FF;    
    }    
    input {  
        border: 2px solid #ccc;  
        font-size: 1rem;  
        font-weight: 100;  
        font-family: 'Lato';  
        padding: 10px;  
    }  
    form {  
        margin: 20px auto;  
        padding: 20px;  
        border: 5px solid #ccc;  
        background: #8bb2eafa;  
    }  
    h1 {  
        font-family: sans-serif;  
      display: block;  
      font-size: 2rem;  
      font-weight: bold;  
      text-align: center;  
      letter-spacing: 3px;  
      color: hotpink;  
        text-transform: uppercase;  
    }  
        input[type=submit] {    
      border: 3px solid;    
      border-radius: 2px;    
      color: ;    
      display: block;    
      font-size: 1em;    
      font-weight: bold;    
      margin: 1em auto;    
      padding: 1em 4em;    
     position: relative;    
      text-transform: uppercase;    
    }    
    input[type=submit]::before   
    {    
      background: #fff;    
      content: '';    
      position: absolute;    
      z-index: -1;    
    }    
    input[type=submit]:hover {    
      color: #1A33FF;    
    }    
    </style>  
    </head>  
    <body>  
    <h1> PHP Registration Form Example </h1>  
    <form method="post" enctype="multipart/form-data" action =?#?>  
    <table>  
     <tr>  
        <td colspan="2"> <?php echo @$msg; ?> </td>  
     </tr>  
      <tr>  
        <td width="159"> <b> Enter your Name </b> </td>  
        <td width="218">  
        <input type="text" placeholder="Enter name" name = "n"  pattern="[a-z A-Z]*" required /> </td>  
      </tr>  
      <tr>  
        <td> <b> Enter your Email </b> </td>  
        <td> <input type="email" name="e"/ placeholder= "Enter Email" > </td>  
      </tr>  
      <tr>  
        <td> <b> Enter your Password </b> </td>  
        <td> <input type="password" name="p"/ placeholder=" Enter Password" > </td>  
      </tr>  
      <tr>  
        <td> <b> Enter your Address </b> </td>  
        <td> <textarea name="add">  Enter Address </textarea> </td>  
      </tr>  
      <tr>  
        <td> <b> Enter your Mobile Number </b> </td>  
        <td> <input type="text" pattern="[0-9]*" name="m" / placeholder=" Enter number" > </td>  
      </tr>  
      <tr>  
        <td height="23"> <b> Select your Gender </b> </td>  
        <td>  
        Male <input type="radio" name="g" value="m"/>  
        Female <input type="radio" name="g" value="f"/>  
        </td>  
      </tr>  
      <tr>  
        <td> <b> Choose your Hobbies </b> </td>  
        <td>  
            Cricket <input type="checkbox" value="cricket" name="hobb[]"/>  
            Singing <input type="checkbox" value="singing" name="hobb[]"/>  
            Dancing <input type="checkbox" value="dancing" name="hobb[]"/>  
        </td>  
      </tr>  
      <tr>  
        <td> <b> Select your Profile Pic </b> </td>  
        <td> <input type="file" name="pic"/> </td>  
      </tr>  
      <tr>  
        <td> <b> Select your Date of Birth </b> </td>  
        <td>  
            <select name="mm">  
                <option value=""> Month </option>  
                <?php   
                for($i=1;$i<=12;$i++)  
                {  
                echo "<option value ='$i'>".$i."</option>";  
                }  
                ?>  
            </select>  
            <select name="dd">  
                <option value=""> Date </option>  
                <?php   
                for($i=1;$i<=31;$i++)  
                {  
                echo "<option value ='$i'>".$i."</option>";  
                }  
                ?>  
            </select>  
            <select name="yy">  
                <option value=""> Year </option>  
                <?php   
                for($i=1900;$i<=2015;$i++)  
                {  
                echo "<option value ='$i'>".$i."</option>";  
                }  
                ?>  
            </select>  
        </td>  
      </tr>  
      <tr>  
        <td colspan="2" align="center">  
        <input type ="submit" name="save" value="Register"/>  
        <input type="reset" value="Reset"/>  
        </td>  
      </tr>  
    </table>  
    </form>  
    </body>  
    </html>  
    <?php  
    extract($_POST);  
    if(isset($save))  
    {  
    $dob=$yy."-".$mm."--".$dd;  
    $h=implode(",",$hobb);  
    $img=$_FILES['pic']['name'];  
    if($return)  
    {  
    $msg="<font color='red'>".ucfirst($e)." already exists choose another email </font>";  
    }  
    else  
    {  
    $msg= "<font color='blue'> your data saved </font>";  
    }  
    }  
    ?>  
    

    Explanation: In this above example, we have created a basic registration form with the help of PHP.

    Output:

    <img loading=

    PHP Interview Questions with Answer (updated) – DeepCrazyWorld

    Additional Reading

    • SEO Practices Everyone Should Follow SEO Rules
    • Complete Top SEO Checklist
    • Yoast Seo Premium 15.2 Nulled – WordPress SEO Plugin
    • Top 50+ SEO Interview Questions
    • What is a Backlink? How to Get More Backlinks
    • TCS INTERVIEW QUESTIONS – CLICKE HERE
    • Top 20 Interview Program Questions
    • Android Projects with Source Code
    • Python Project With Source Code
    • Python Projects Ideas
    • Machine Learning MCQ Questions
    • Highest Paying Earning Website 
    • School Database Management System 
    • Top 20 Company Interview Questions

    you can read more articles like this here.

    READ MORE

    If you found this post useful, don’t forget to share this with your friends, and if you have any query feel free to comment it in the comment section.

    Thank you 🙂 Keep Learning !

    Share. Facebook Twitter LinkedIn WhatsApp Telegram Pinterest Reddit Email
    Previous ArticleTop 10 Node js Project Ideas & Topics 2021-22 (UPDATED)
    Next Article PHP Interview Questions with Answer (updated) – DeepCrazyWorld

    Related Posts

    Covid-19 Tracker App(Coronavirus Tracker) source code 2023

    ANDROID APP 3 Mins Read

    Online Food Ordering System using PHP/MySQL 2023

    ANDROID APP 3 Mins Read

    E-Commerce Android App with Full Source Code 2023

    ANDROID APP 3 Mins Read

    Create Simple Android Login Application with android studio

    ANDROID APP 4 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • Implementing a Dynamic FAQ Screen UI in Flutter Using ExpansionTile March 29, 2025
    • Creating an Instruction UI Screen in Flutter Application March 29, 2025
    • Animated Backgrounds in Flutter: A Complete Guide March 15, 2025
    • How to make Diary App using flutter stepwise using getx August 31, 2024
    • How to Create Music Player UI screen with fully functional in flutter August 30, 2024
    • How to make ListView Builder Ui in flutter with Source Code August 29, 2024
    • Create a TabBar View in flutter with fully functional stepwise August 28, 2024
    • How to create TabBar view in flutter with source code step wise August 27, 2024
    • How to make Heart rate measure app with Flutter stepwise August 26, 2024
    • How to make ChatGpt App in flutter with source code Stepwise August 25, 2024
    Facebook Twitter Instagram Pinterest YouTube
    • About
    • Contact
    • Disclaimer
    • Privacy Policy
    Copyright by DeepCrazyWorld © 2025

    Type above and press Enter to search. Press Esc to cancel.