<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: HMA WebDesign</title>
    <description>The latest articles on DEV Community by HMA WebDesign (@hmawebdesign).</description>
    <link>https://dev.to/hmawebdesign</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F595567%2F79877cea-55e2-4eb6-81b0-afa037880a28.jpg</url>
      <title>DEV Community: HMA WebDesign</title>
      <link>https://dev.to/hmawebdesign</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hmawebdesign"/>
    <language>en</language>
    <item>
      <title>Send Email in PHP Using PHPMailer | Gmail SMTP Phpmailer</title>
      <dc:creator>HMA WebDesign</dc:creator>
      <pubDate>Mon, 27 May 2024 20:16:28 +0000</pubDate>
      <link>https://dev.to/hmawebdesign/how-to-receive-email-from-html-form-using-php-1g8n</link>
      <guid>https://dev.to/hmawebdesign/how-to-receive-email-from-html-form-using-php-1g8n</guid>
      <description>&lt;p&gt;In this post, you will learn to send Email in PHP Using PHPMailer | Gmail SMTP Phpmailer and how to Receive Emails from HTML forms using PHP.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is PHP Mailer?
&lt;/h2&gt;

&lt;p&gt;Before we dive into the details, let’s briefly introduce PHP Mailer. PHP Mailer is a robust PHP library that simplifies the process of sending emails through PHP scripts. It offers an intuitive and feature-rich interface for sending plain text and HTML emails, complete with attachments and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps – Send HTML Form via PHP Mailer
&lt;/h2&gt;

&lt;p&gt;Let’s start with a detailed outline that will guide us to Send HTML Forms via PHP Mailer through this extensive guide. Here are the important steps to Send an HTML Form via PHP Mailer on HTML form submission:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download and install PHP Mailer from GitHub&lt;/li&gt;
&lt;li&gt;Setup your HTML Contact Form&lt;/li&gt;
&lt;li&gt;Include PHP Mailer in your HTML code&lt;/li&gt;
&lt;li&gt;Configure PHP Mailer&lt;/li&gt;
&lt;li&gt;Process form data to send email&lt;/li&gt;
&lt;li&gt;Compose the Email&lt;/li&gt;
&lt;li&gt;Handle Success and Error messages&lt;/li&gt;
&lt;li&gt;Send the Email&lt;/li&gt;
&lt;li&gt;Video Tutorial – Send HTML Form via PHP Mailer&lt;/li&gt;
&lt;li&gt;Now that we have our roadmap, let’s explore each section in detail to Send HTML Forms via PHP Mailer.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step-by-Step Video Tutorial:
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/s5E0ekvEH18"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Send HTML Form to Email Using PHP Mailer
&lt;/h2&gt;

&lt;p&gt;Sending HTML forms via email is a seamless process when you have PHP Mailer at your disposal. Here’s a step-by-step guide to achieving, how to send HTML form via PHP Mailer:&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before diving into implementation, ensure that you have the following prerequisites in place:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Web Server with PHP Support:&lt;/strong&gt; You’ll need a web server, such as Apache or Google, with PHP support to run your PHP Mailer script.&lt;br&gt;
Email Server Access: Ensure you have access to an email server or SMTP server to send emails, such as Gmail.&lt;br&gt;
Basic HTML and PHP Knowledge: Familiarize yourself with HTML to create the form and PHP to process it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Let’s start by downloading PHP Mailer and setting up our HTML form to Send HTML Form via PHP Mailer:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Download and install PHP Mailer&lt;/strong&gt;&lt;br&gt;
Begin by downloading the PHP Mailer library. You can obtain it from the official GitHub repository or use Composer if you prefer package management.&lt;/p&gt;

&lt;p&gt;To Download the PHP Mailer manually from the GitHub library &lt;a href="https://github.com/PHPMailer/PHPMailer"&gt;Click Here&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;If you want to install the PHPMailer using Composer. First of all, simply install the &lt;a href="https://getcomposer.org/"&gt;Composer Setup&lt;/a&gt; on your computer and run the following command in your terminal:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;u&gt;&lt;strong&gt;composer require phpmailer/phpmailer&lt;/strong&gt;&lt;/u&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Alternatively, if you’re not using Composer, you can &lt;a href="https://github.com/PHPMailer/PHPMailer/archive/master.zip"&gt;download PHPMailer&lt;/a&gt; as a zip file, and then copy the contents of the PHPMailer folder into one of the include_path directories specified in your PHP configuration and load each class file manually:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Set Up Your HTML Form&lt;/strong&gt;&lt;br&gt;
Create an HTML form on your website where users can submit their information. Ensure that your form fields have appropriate name attributes.&lt;/p&gt;
&lt;h2&gt;
  
  
  HTML Form Source Code
&lt;/h2&gt;

&lt;p&gt;I have created a simple HTML form to send web form data to email using PHPMailer. I will collect this form data from the user and send it to my email address using PHPMailer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
  &amp;lt;title&amp;gt;Contact Form&amp;lt;/title&amp;gt;
  &amp;lt;style&amp;gt;
    body{
    background-color: aliceblue;}
    .contact {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      transition: 1s;
    }

    .contact .input-box input,
    textarea {
      width: 100%;
      height: 35px;
      padding: 20px;
      letter-spacing: 1px;
      outline: none;
      border: 1px solid rgba(0, 0, 0, 0.61);
      /* border: 2px solid rgb(238, 224, 243); */
      border-radius: 5px;
      margin: 0;
      margin-bottom: 10px;
      box-shadow: 0 1px rgba(0, 0, 0, 0.233);
      resize: none;
      box-sizing: border-box;
    }

    .contact .input-box input:focus {
      border: 1px solid rgb(0, 128, 255);
    }

    .contact .input-box textarea:focus {
      border: 1px solid dodgerblue;
    }

    .contact .input-box textarea {
      height: 100%;
    }

    ::placeholder {
      color: rgba(0, 0, 0, 0.521);
      letter-spacing: 0;
      font-size: 15px;
    }

    .contact .submit-btn input {
      width: 100%;
      height: 35px;
      border: none;
      /* background-color: rgba(17, 135, 253, 0.952); */
      border: 1px solid rgb(0, 128, 255);
      ;
      background-color: transparent;
      border-radius: 3px;
      color: rgb(0, 128, 255);
      font-size: 20px;
      font-family: serif;
      padding: 0 8px;
      box-shadow: 0 3px 3px rgba(0, 0, 0, 0.116);
      border-radius: 5px;
      outline: none;
      cursor: pointer;
      transition: 0.3s ease-in-out;
    }

    .contact .submit-btn input:hover {
      background-color: rgb(0, 128, 255);
      color: white;
    }

    h2 {
      color: rgb(0, 128, 255);
      text-align: center;
      font-size: 30px;
    }
  &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
  &amp;lt;div class="contact"&amp;gt;
    &amp;lt;h2&amp;gt;Contact Now&amp;lt;/h2&amp;gt;
    &amp;lt;form action="mail.php" method="post"&amp;gt;
      &amp;lt;div class="input-box"&amp;gt;
        &amp;lt;input type="text" name="name" placeholder="Your name"&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div class="input-box"&amp;gt;
        &amp;lt;input type="email" name="email" placeholder="Email Address"&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div class="input-box"&amp;gt;
        &amp;lt;textarea name="message" cols="25" rows="7" placeholder="Type your message"&amp;gt;&amp;lt;/textarea&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div class="submit-btn"&amp;gt;
        &amp;lt;input type="submit" name="send" value="Send Message"&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Include PHP Mailer&lt;/strong&gt;&lt;br&gt;
In your PHP script, include the PHP Mailer library using require or require_once. as shown in the following script:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Configure PHP Mailer&lt;/strong&gt;&lt;br&gt;
Set up PHP Mailer with your email server details, including the SMTP host, username, password, and port. Make sure to use valid credentials and a secure connection.&lt;/p&gt;

&lt;p&gt;If you are using a Gmail SMTP server, first of all, login to your Gmail ID, turn on 2-step authentication and, generate an App Password. To generate an App Password in your Gmail account &lt;strong&gt;&lt;a href="https://myaccount.google.com/apppasswords"&gt;follow this link&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Process Form Data&lt;/strong&gt;&lt;br&gt;
In your PHP script, retrieve the form data submitted by the user using $_POST or $_GET, depending on your form’s method attribute. In this tutorial, we have received the following form data from the user:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Compose the Email&lt;/strong&gt;&lt;br&gt;
Use PHP Mailer to compose your email. You can format it as plain text or HTML, depending on your preference. Here is the complete PHPMailer source code to send HTML form via PHP Mailer:&lt;/p&gt;
&lt;h2&gt;
  
  
  PHPMailer Source Code
&lt;/h2&gt;

&lt;p&gt;Copy the below source code and change the data according to your preferences:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

//required files
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';

//Create an instance; passing `true` enables exceptions
if (isset($_POST["send"])) {

  $mail = new PHPMailer(true);

    //Server settings
    $mail-&amp;gt;isSMTP();                              //Send using SMTP
    $mail-&amp;gt;Host       = 'smtp.gmail.com';       //Set the SMTP server to send through
    $mail-&amp;gt;SMTPAuth   = true;             //Enable SMTP authentication
    $mail-&amp;gt;Username   = 'your email address';   //SMTP write your email
    $mail-&amp;gt;Password   = 'app password';      //SMTP password
    $mail-&amp;gt;SMTPSecure = 'ssl';            //Enable implicit SSL encryption
    $mail-&amp;gt;Port       = 465;                                    

    //Recipients
    $mail-&amp;gt;setFrom( $_POST["email"], $_POST["name"]); // Sender Email and name
    $mail-&amp;gt;addAddress('example@gmail.com');     //Add a recipient email  
    $mail-&amp;gt;addReplyTo($_POST["email"], $_POST["name"]); // reply to sender email

    //Content
    $mail-&amp;gt;isHTML(true);               //Set email format to HTML
    $mail-&amp;gt;Subject = $_POST["subject"];   // email subject headings
    $mail-&amp;gt;Body    = $_POST["message"]; //email message

    // Success sent message alert
    $mail-&amp;gt;send();
    echo
    " 
    &amp;lt;script&amp;gt; 
     alert('Message was sent successfully!');
     document.location.href = 'index.php';
    &amp;lt;/script&amp;gt;
    ";
}
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Handle Success and Error messages&lt;/strong&gt;&lt;br&gt;
Implement error handling to deal with scenarios where the email-sending process might fail. Display a success message to the user upon successful submission.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Send the Email&lt;/strong&gt;&lt;br&gt;
Use the send method to send the email. Ensure to implement error handling to deal with scenarios where the email-sending process might fail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Testing Your Setup&lt;/strong&gt;&lt;br&gt;
After implementing the above steps, thoroughly test your setup. Submit test data through your HTML form to ensure that emails are being sent correctly to the specified email address.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In conclusion, PHP Mailer is a powerful tool that simplifies the process of sending HTML forms to email addresses. By following the steps outlined in this guide, you can enhance user interaction on your website and efficiently collect user information, feedback, and inquiries. Remember to handle errors gracefully and ensure the security of user data during transmission.&lt;/p&gt;

&lt;p&gt;Now, let’s address some frequently asked questions (FAQs) related to PHP Mailer and email functionality.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>php</category>
      <category>email</category>
    </item>
    <item>
      <title>How to Add Scroll to Top Button on Your Website HTML CSS</title>
      <dc:creator>HMA WebDesign</dc:creator>
      <pubDate>Thu, 21 Mar 2024 07:09:13 +0000</pubDate>
      <link>https://dev.to/hmawebdesign/how-to-add-scroll-to-top-button-on-your-website-html-css-28g2</link>
      <guid>https://dev.to/hmawebdesign/how-to-add-scroll-to-top-button-on-your-website-html-css-28g2</guid>
      <description>&lt;p&gt;Scrolling down a page is a common occurrence on websites. But what if you want to go back to the top of the page? You can create a scroll to top button on your website to make this easy. In this blog post, we’ll show you how to add a scroll to top button on your website in just a few simple steps.&lt;/p&gt;

&lt;p&gt;Scrolling through pages of content can be a tedious task, but with the scroll to top button on your website, it can be a breeze. Adding this simple button to your website can make it easier for users to get the information they want faster. In this blog post, we will show you how to add the scroll to top button on your website.&lt;/p&gt;

&lt;p&gt;Follow these easy steps to add a Scroll-to-Top or Back to top Button on your Website:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First, add the HTML Button code below to your web page, inside the footer area.&lt;/li&gt;
&lt;li&gt;Add the top button icon using the Font Awesome site kit.&lt;/li&gt;
&lt;li&gt;Then, add the CSS styling to the main stylesheet of your website.&lt;/li&gt;
&lt;li&gt;After that, create a new file named scroll.js, and add JavaScript code to it.&lt;/li&gt;
&lt;li&gt;Link the JavaScript file to the top button page.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Video Tutorial – Adding Back to Top Button in HTML
&lt;/h2&gt;

&lt;p&gt;Watch the video tutorial on how to create ascroll to top button on your website using HTML, CSS, and JavaScript:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/80vQ4VSAh2I"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1- Add Top Button HTML Code
&lt;/h2&gt;

&lt;p&gt;First, It’s time to get the HTML scroll to top button on your website code. Add this code line on the footer area, where you want to place the back to the top button.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button onclick="topFunction()" id="myBtn" title="Scroll to Top"&amp;gt;
    &amp;lt;!-- font awesome up arrow icon --&amp;gt;
    &amp;lt;i class="fas fa-angle-double-up"&amp;gt;&amp;lt;/i&amp;gt; 
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2-Top Button Icon Using the Font Awesome site kit
&lt;/h2&gt;

&lt;p&gt;In this step, we are adding the up arrow icon inside the scroll to top button on your website using the &lt;a href="https://fontawesome.com/docs/web/setup/use-kit"&gt;font awesome kit&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;To use the Free Font Awesome 6 icons, you can sign up for an account at Font Awesome. And get a code (called KIT CODE) to use when you add Font Awesome to get scroll to top button on your website.&lt;/p&gt;

&lt;p&gt;I prefer the KIT CODE approach. Once you get the code you can start using Font Awesome on your web pages. Include only one line of HTML code in the header section of the web page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script src="https://kit.fontawesome.com/yourcode.js" crossorigin="anonymous"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get the code to your email like that a076d05399.js and by inserting the script tag, with the code, you can start using Font Awesome icons.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3- Add the CSS styling
&lt;/h2&gt;

&lt;p&gt;After that add the following CSS source code to the main style sheet of your website to style scroll to top button on your website.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#myBtn {
  display: none; /* Hidden by default */
  position: fixed; /* Fixed/sticky position */
  bottom: 10px; /* Place the button at the bottom of the page */
  right: 10px; /* Place the button 30px from the right */
  z-index: 99; /* Make sure it does not overlap */
  border: none; /* Remove borders */
  outline: none; /* Remove outline */
  background-color: rgba(0, 11, 160, 0.815); /* Set a background color */
  color: white; /* Text color */
  cursor: pointer; /* Add a mouse pointer on hover */
  padding: 0px 15px; /* Some padding */
  border-radius: 10px; /* Rounded corners */
  font-size: 30px; /* Increase font size */
}
#myBtn:hover {
  background-color: rgb(0, 0, 0); /* Add a dark-grey background on hover */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4- Add JavaScript Code
&lt;/h2&gt;

&lt;p&gt;Now, create a new javascript file named scroll.js and add the following code for scroll to top button on your website.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Get the Top button:
mybutton = document.getElementById("myBtn");
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function () {
 scrollFunction();
};
function scrollFunction() {
 if (document.body.scrollTop &amp;gt; 20 || document.documentElement.    scrollTop &amp;gt; 20) {
    mybutton.style.display = "block";
 } else {
  mybutton.style.display = "none";
 }
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
 document.body.scrollTop = 0; // For Safari
 document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 5- Link the JavaScript&lt;br&gt;
Finally, link the JavaScript (scroll.js) file to the web page where you want to place the go to the top button. To link the javascript file to the web page use the following one-line code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script src="scroll.js"&amp;gt;&amp;lt;/script&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final Words
&lt;/h2&gt;

&lt;p&gt;If you’re looking for a way to improve your website’s user experience, consider adding a scroll to top button on your website. &lt;/p&gt;

</description>
      <category>html</category>
      <category>career</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Simple Calculator App in HTML CSS and JavaScript</title>
      <dc:creator>HMA WebDesign</dc:creator>
      <pubDate>Thu, 21 Mar 2024 06:50:51 +0000</pubDate>
      <link>https://dev.to/hmawebdesign/simple-calculator-app-in-html-css-and-javascript-49c0</link>
      <guid>https://dev.to/hmawebdesign/simple-calculator-app-in-html-css-and-javascript-49c0</guid>
      <description>&lt;p&gt;Are you ready to embark on an exciting journey into the world of web development? Building a simple calculator app in HTML CSS, and JavaScript is an excellent starting point.&lt;/p&gt;

&lt;p&gt;In this comprehensive guide, we will walk you through the process step by step, from setting up your project to adding functionality and styling. By the end of this tutorial, you’ll have a fully functional calculator app that you can proudly showcase. &lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites – Simple Calculator App in HTML CSS
&lt;/h2&gt;

&lt;p&gt;To successfully build the simple calculator app in HTML CSS, you’ll need the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;HTML: This will be the structure of your app.&lt;/li&gt;
&lt;li&gt;CSS: For styling and making your calculator visually appealing.&lt;/li&gt;
&lt;li&gt;JavaScript: To add functionality and perform calculations.&lt;/li&gt;
&lt;li&gt;A code editor: Choose a code editor of your preference. Some popular options include Visual Studio Code, Sublime Text, or Atom.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Video Tutorial
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/FfSJeeYMOIk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML: Building the Structure
&lt;/h2&gt;

&lt;p&gt;In this section, we’ll create the HTML structure for our calculator app. The HTML file serves as the backbone of our application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Simple Calculator&amp;lt;/title&amp;gt;
    &amp;lt;link rel="stylesheet" type="text/css" href="styles.css"&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;div class="calculator"&amp;gt;
        &amp;lt;input type="text" id="display" disabled&amp;gt;
        &amp;lt;div class="keypad"&amp;gt;
            &amp;lt;button class="operator" onclick="appendValue('/')"&amp;gt;/&amp;lt;/button&amp;gt;
            &amp;lt;button class="operator" onclick="appendValue('*')"&amp;gt;x&amp;lt;/button&amp;gt;
            &amp;lt;button onclick="appendValue('7')"&amp;gt;7&amp;lt;/button&amp;gt;
            &amp;lt;button onclick="appendValue('8')"&amp;gt;8&amp;lt;/button&amp;gt;
            &amp;lt;button onclick="appendValue('9')"&amp;gt;9&amp;lt;/button&amp;gt;
            &amp;lt;button class="operator" onclick="appendValue('-')"&amp;gt;-&amp;lt;/button&amp;gt;
            &amp;lt;button onclick="appendValue('4')"&amp;gt;4&amp;lt;/button&amp;gt;
            &amp;lt;button onclick="appendValue('5')"&amp;gt;5&amp;lt;/button&amp;gt;
            &amp;lt;button onclick="appendValue('6')"&amp;gt;6&amp;lt;/button&amp;gt;
            &amp;lt;button class="operator" onclick="appendValue('+')"&amp;gt;+&amp;lt;/button&amp;gt;
            &amp;lt;button onclick="appendValue('1')"&amp;gt;1&amp;lt;/button&amp;gt;
            &amp;lt;button onclick="appendValue('2')"&amp;gt;2&amp;lt;/button&amp;gt;
            &amp;lt;button onclick="appendValue('3')"&amp;gt;3&amp;lt;/button&amp;gt;
            &amp;lt;button id="clear-btn" onclick="clearDisplay()"&amp;gt;C&amp;lt;/button&amp;gt;
            &amp;lt;button onclick="appendValue('0')"&amp;gt;0&amp;lt;/button&amp;gt;
            &amp;lt;button id="calculate-btn" onclick="calculate()"&amp;gt;=&amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CSS: Adding Style
&lt;/h2&gt;

&lt;p&gt;simple calculator app in HTML CSS&lt;br&gt;
Next, let’s style our calculator to make it visually appealing. Create a style.css file and add the following CSS code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.calculator {
    width: 250px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f0f0f0;
    box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.2);
    border-radius: 5px;
}

#display {
    width: 100%;
    height: 30px;
    margin-bottom: 10px;
    padding: 5px;
}

.keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 10px;
}

button {
    width: 100%;
    height: 30px;
    font-size: 14px;
}

button.operator {
    background-color: #ff9933;
    color: #fff;
    font-weight: bold;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  JavaScript: Adding Functionality
&lt;/h2&gt;

&lt;p&gt;Now comes the exciting part – adding functionality to our calculator using JavaScript. Create a script.js file and add the following JavaScript code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Function to append the clicked button value to the display
function appendValue(value) {
    // Your code here
}

// Function to clear the display
function clearDisplay() {
    // Your code here
}

// Function to evaluate and display the result
function calculate() {
    // Your code here
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Congratulations! You’ve just learned how to create a simple calculator app in HTML CSS, and JavaScript. This project is a fantastic way to kick-start your web development journey. Keep practicing, and exploring advanced features, and soon you’ll be building more complex web applications.&lt;/p&gt;

</description>
      <category>html</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Create Complete User Registration Form in PHP and MySQL</title>
      <dc:creator>HMA WebDesign</dc:creator>
      <pubDate>Thu, 21 Mar 2024 06:35:47 +0000</pubDate>
      <link>https://dev.to/hmawebdesign/create-complete-user-registration-form-in-php-and-mysql-3k8i</link>
      <guid>https://dev.to/hmawebdesign/create-complete-user-registration-form-in-php-and-mysql-3k8i</guid>
      <description>&lt;h2&gt;
  
  
  What You Will Learn?
&lt;/h2&gt;

&lt;p&gt;As stated previously, in this article, you are going to learn the following important concepts while creating the complete user registration form in PHP and using the MySQL database.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to create a user registration form in HTML and CSS?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;How to create a new MySQL database in PHPMyAdmin?&lt;/li&gt;
&lt;li&gt;How to connect with MySQL database with PHP?&lt;/li&gt;
&lt;li&gt;How to do registration form validation in PHP?&lt;/li&gt;
&lt;li&gt;Password encryption or password hashing in PHP?&lt;/li&gt;
&lt;li&gt;How to insert or update user data into the database table?&lt;/li&gt;
&lt;li&gt;How to use $_session variable in the PHP user registration and login form?&lt;/li&gt;
&lt;li&gt;How to set the cookies variable in PHP for user registration?&lt;/li&gt;
&lt;li&gt;How to create a User logout PHP code?&lt;/li&gt;
&lt;li&gt;How to create a user login system in PHP?&lt;/li&gt;
&lt;li&gt;How to write PHP code for the user login form?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Video Tutorial – Login Register PHP
&lt;/h2&gt;

&lt;p&gt;Meanwhile, You can watch the following video tutorial which includes the step-by-step process to create a complete user registration form using PHP and MySQL databases.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/m50q5_RQFB4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps – Login and Register for PHP Form
&lt;/h2&gt;

&lt;p&gt;More importantly, to create a complete user registration system in PHP and MySQL, we are going to adopt the following approach. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First of all, we are going to create the following PHP files:&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;Create an index.php file. This file contains the HTML and CSS code for the user Sign up form.&lt;/li&gt;
&lt;li&gt;Create a new MySql database in PHPMyAdmin and a new user table where you want to store the user login details.&lt;/li&gt;
&lt;li&gt;Create a linkDB.php file. This file will contain MYSQL database connection PHP code.&lt;/li&gt;
&lt;li&gt;Create a server.php file. This file will contain all server-side PHP and MYSQL database codes for user registration and user login forms. This file is linked with both, index.php and login.php files using the PHP include function.&lt;/li&gt;
&lt;li&gt;Create a LoggedInPage.php file. This will be your home page, and after the successfully logged user in, will redirect to this home page.&lt;/li&gt;
&lt;li&gt;Create a login.php file. This file contains the login form HTML and CSS code.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Source Code – (index.php File)
&lt;/h2&gt;

&lt;p&gt;The following HTML CSS source code belongs to the index.php file. This code is for the user registration form in PHP.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- PHP command to link server.php file with registration form  --&amp;gt;
&amp;lt;?php include('server.php'); ?&amp;gt;

 &amp;lt;!DOCTYPE html&amp;gt;
 &amp;lt;html lang="en"&amp;gt;
 &amp;lt;head&amp;gt;
     &amp;lt;meta charset="UTF-8"&amp;gt;
     &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
     &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
     &amp;lt;title&amp;gt;Registration&amp;lt;/title&amp;gt;

     &amp;lt;!-- CSS Code --&amp;gt;
     &amp;lt;style&amp;gt;
         .container{
             justify-content: center;
             text-align: center;
             align-items: center;
         }
         input{
             padding: 5px;
         }
         .error{
             background-color: pink;
             color: red;
             width: 300px;
             margin: 0 auto;
         }
     &amp;lt;/style&amp;gt;
 &amp;lt;/head&amp;gt;

 &amp;lt;body&amp;gt;
 &amp;lt;div class="container"&amp;gt;
     &amp;lt;h1&amp;gt;User Registration System&amp;lt;/h1&amp;gt;
     &amp;lt;h4&amp;gt;&amp;lt;a href="loggedInPage.php"&amp;gt;Home Page&amp;lt;/a&amp;gt;&amp;lt;/h4&amp;gt;


     &amp;lt;div class="form" id="signUp"&amp;gt;
     &amp;lt;form method="POST"&amp;gt;
        &amp;lt;div class="error"&amp;gt; &amp;lt;?php echo $error ?&amp;gt; &amp;lt;/div&amp;gt;

            &amp;lt;!--------- To check user regidtration status -------&amp;gt;
     &amp;lt;p&amp;gt;
         &amp;lt;?php
            if (!isset($_COOKIE["id"]) OR !isset($_SESSION["id"]) ) {
             echo "Please first register to proceed.";
            }
         ?&amp;gt;
        &amp;lt;/p&amp;gt;
       &amp;lt;input type="text" name="name" placeholder="User Name"&amp;gt; &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;
       &amp;lt;input type="email" name="email" placeholder="Email"&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
       &amp;lt;input type="password" name="password" placeholder="password"&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
       &amp;lt;input type="password" name="repeatPassword" placeholder="Repeat Password"&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
       &amp;lt;label for="checkbox"&amp;gt;Stay logged in&amp;lt;/label&amp;gt;
       &amp;lt;input type="checkbox" name="stayLoggedIn" id="chechbox" value="1"&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
       &amp;lt;input type="submit" name="signUp" value="Sign Up"&amp;gt;
       &amp;lt;p &amp;gt;Have an account already? &amp;lt;a href="logIn.php"&amp;gt;Log In&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
      &amp;lt;/form&amp;gt;
     &amp;lt;/div&amp;gt;

 &amp;lt;/body&amp;gt;
 &amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Source Code – (login.php File)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- PHP command to link server.php file with registration form  --&amp;gt;
&amp;lt;?php include('server.php'); ?&amp;gt;

 &amp;lt;!DOCTYPE html&amp;gt;
 &amp;lt;html lang="en"&amp;gt;
 &amp;lt;head&amp;gt;
     &amp;lt;meta charset="UTF-8"&amp;gt;
     &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
     &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
     &amp;lt;title&amp;gt;User logIn&amp;lt;/title&amp;gt;

     &amp;lt;style&amp;gt;
         .container{
             justify-content: center;
             text-align: center;
             align-items: center;
         }
         input{
             padding: 5px;
         }
         .error{
             background-color: pink;
             color: red;
             width: 300px;
             margin: 0 auto;
         }
     &amp;lt;/style&amp;gt;
 &amp;lt;/head&amp;gt;
 &amp;lt;body&amp;gt;
 &amp;lt;div class="container"&amp;gt;
     &amp;lt;h1&amp;gt; User Registration System&amp;lt;/h1&amp;gt;

     &amp;lt;h4&amp;gt;&amp;lt;a href="loggedInPage.php"&amp;gt;Home Page&amp;lt;/a&amp;gt;&amp;lt;/h4&amp;gt;
                      &amp;lt;!--------log in form------&amp;gt;

     &amp;lt;div class="logInForm" id="logIn"&amp;gt;
     &amp;lt;form method="POST"&amp;gt;

     &amp;lt;!-- To show errors is user put wrong data --&amp;gt;
        &amp;lt;div class="error"&amp;gt; &amp;lt;?php echo $error2 ?&amp;gt; &amp;lt;/div&amp;gt;

        &amp;lt;!-- To check the user loged In status --&amp;gt;
        &amp;lt;p&amp;gt;
         &amp;lt;?php
            if (!isset($_COOKIE["id"]) OR !isset($_SESSION["id"]) ) {
             echo "&amp;lt;p&amp;gt;Please first log in to proceed.&amp;lt;/p&amp;gt;";
            }
         ?&amp;gt;
       &amp;lt;/p&amp;gt;

       &amp;lt;input type="email" name="email" placeholder="Email"&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
       &amp;lt;input type="password" name="password" placeholder="password"&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
       &amp;lt;label for="checkbox"&amp;gt;Stay logged in&amp;lt;/label&amp;gt;
       &amp;lt;input type="checkbox" name="stayLoggedIn" id="chechbox" value="1"&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
       &amp;lt;input type="submit" name="logIn" value="Log In"&amp;gt;

       &amp;lt;!-- User registration form link --&amp;gt;
       &amp;lt;p&amp;gt;Not a register user &amp;lt;a href="index.php"&amp;gt; Create Account&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
     &amp;lt;/form&amp;gt;
     &amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;

 &amp;lt;/script&amp;gt;

 &amp;lt;/body&amp;gt;
 &amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Source Code – (linkDB.php File)
&lt;/h2&gt;

&lt;p&gt;The linkDB.php includes the following PHP code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
// Open a new connection to the MySQL server
$linkDB = mysqli_connect("localhost","my_user_name","my_password","my_db_name");  
  if (mysqli_connect_error()){ //for connection error finding
  die ('There was an error while connecting to database');
  }
    ?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Source Code – (server.php File)
&lt;/h2&gt;

&lt;p&gt;The following back-end code for the user registration form in PHP will be included in the server.php file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php 
session_start();
//------ PHP code for User registration form---
$error = "";
if (array_key_exists("signUp", $_POST)) {

     // Database Link
    include('linkDB.php');  

    //Taking HTML Form Data from User
    $name = mysqli_real_escape_string($linkDB, $_POST['name']);
    $email = mysqli_real_escape_string($linkDB, $_POST['email']);
    $password = mysqli_real_escape_string($linkDB,  $_POST['password']); 
    $repeatPassword = mysqli_real_escape_string($linkDB,  $_POST['repeatPassword']); 

    // PHP form validation PHP code
    if (!$name) {
      $error .= "Name is required &amp;lt;br&amp;gt;";
     }
    if (!$email) {
        $error .= "Email is required &amp;lt;br&amp;gt;";
     }
    if (!$password) {
        $error .= "Password is required &amp;lt;br&amp;gt;";
     } 
     if ($password !== $repeatPassword) {
        $error .= "Password does not match &amp;lt;br&amp;gt;";
     }
     if ($error) {
        $error = "&amp;lt;b&amp;gt;There were error(s) in your form!&amp;lt;/b&amp;gt; &amp;lt;br&amp;gt;".$error;
     }  else {

        //Check if email is already exist in the Database

        $query = "SELECT id FROM users WHERE email = '$email'";
        $result = mysqli_query($linkDB, $query);
        if (mysqli_num_rows($result) &amp;gt; 0) {
            $error .="&amp;lt;p&amp;gt;Your email has taken already!&amp;lt;/p&amp;gt;";
        } else {

            //Password encryption or Password Hashing
            $hashedPassword = password_hash($password, PASSWORD_DEFAULT); 
            $query = "INSERT INTO users (name, email, password) VALUES ('$name', '$email', '$hashedPassword')";

            if (!mysqli_query($linkDB, $query)){
                $error ="&amp;lt;p&amp;gt;Could not sign you up - please try again.&amp;lt;/p&amp;gt;";
                } else {

                    //session variables to keep user logged in
                $_SESSION['id'] = mysqli_insert_id($linkDB);  
                $_SESSION['name'] = $name;

                //Setcookie function to keep user logged in for long time
                if ($_POST['stayLoggedIn'] == '1') {
                setcookie('id', mysqli_insert_id($linkDB), time() + 60*60*365);
                //echo "&amp;lt;p&amp;gt;The cookie id is :". $_COOKIE['id']."&amp;lt;/P&amp;gt;";
                }

                //Redirecting user to home page after successfully logged in 
                header("Location: loggedInPage.php");  

                }

            }

        }  
    }

      //-------User Login PHP Code ------------

if (array_key_exists("logIn", $_POST)) {

    // Database Link
    include('linkDB.php'); 

      //Taking form Data From User
      $email = mysqli_real_escape_string($linkDB, $_POST['email']);
      $password = mysqli_real_escape_string($linkDB,  $_POST['password']); 

      //Check if input Field are empty
      if (!$email) {
          $error2 .= "Email is required &amp;lt;br&amp;gt;";
       }
      if (!$password) {
          $error2 .= "Password is required &amp;lt;br&amp;gt;";
       } 
       if ($error2) {
          $error2 = "&amp;lt;b&amp;gt;There were error(s) in your form!&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;".$error2;
       }

      else {        
          //matching email and password

            $query = "SELECT * FROM users WHERE email='$email'";
            $result = mysqli_query($linkDB, $query);
            $row = mysqli_fetch_array($result);

            if (isset($row)) {

                if (password_verify($password, $row['password'])) {

                    //session variables to keep user logged in
                    $_SESSION['id'] = $row['id'];  

                      //Logged in for long time untill user didn't log out
                    if ($_POST['stayLoggedIn'] == '1') {
                    setcookie('id', $row['id'], time() + 60*60*24); //Logged in permanently
                    }

                    header("Location: loggedInPage.php");

                } else {
                    $error2 = "Combination of email/password does not match!";
                     }

            }  else {
                $error2 = "Combination of email/password does not match!";
                 }
        }
}
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  User Logout PHP Code
&lt;/h2&gt;

&lt;p&gt;The below code is used to log out with a session in PHP and log out PHP session.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//PHP code to logout user from website

  if (isset($_GET["logout"])) {
    unset($_SESSION['id']);
    setcookie("id", "", time() - 3600);
    $_COOKIE['id'] = "";
  } 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Final Words&lt;br&gt;
In the above discussion, we have created the registration and login form in PHP and MySQL databases. If you want to implement the above user registration form in PHP on your website then you need to follow the procedures explained in this tutorial. If you still find any difficulty in understanding, feel free to contact this website &lt;a href="http://www.hmawebdesign.com"&gt;www.hmawebdesign.com&lt;/a&gt;. If you found this tutorial helpful please don’t forget to &lt;a href="https://www.youtube.com/channel/UCCj8edobyplMAnhwYvi9n4A?sub_confirmation=1"&gt;SUBSCRIBE YOUTUBE CHANNEL&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Share this Article!&lt;/p&gt;

</description>
      <category>php</category>
      <category>javascript</category>
      <category>backend</category>
      <category>mysql</category>
    </item>
    <item>
      <title>How to Create Weather App in PHP | OpenWeatherMap API</title>
      <dc:creator>HMA WebDesign</dc:creator>
      <pubDate>Thu, 21 Mar 2024 05:26:24 +0000</pubDate>
      <link>https://dev.to/hmawebdesign/how-to-create-weather-app-in-php-openweathermap-api-17lb</link>
      <guid>https://dev.to/hmawebdesign/how-to-create-weather-app-in-php-openweathermap-api-17lb</guid>
      <description>&lt;p&gt;In this article, you will learn How to Create Weather App in PHP and How to Use OpenWeatherMap API Using PHP. Some websites required a weather app to display the current weather conditions to their users.&lt;/p&gt;

&lt;p&gt;We are going to create a weather web application by using a weather API provided by OpenWeatherMap using PHP. By using open weather API, you can get minute weather forecasts, historical data, current state, and from short-term to annual and forecasted weather data.&lt;/p&gt;

&lt;p&gt;Steps to Create Weather App in PHP&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create the basic application front Page using HTML and CSS:&lt;/strong&gt; I have created a basic UI that look like cards and each card displays current location weather information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Get a Weather API key using the Open Weather Map Website:&lt;/strong&gt; You first need to Sign Up before you can generate an API key for your Weather API. After signing up navigate to the API section of the website and select the automatically generated weather API key. Save this API key as you will need this to call from your app. Open Weather Website: &lt;a href="https://openweathermap.org/"&gt;https://openweathermap.org/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Call the weather API using PHP&lt;/strong&gt;: I have used Retrofit for a type-safe HTTP client call. For calling the weather API we need the base URL and the user’s coordinates are parameters.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Video Tutorial (Create Weather App in PHP)
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/VG-oJ8S-K7M"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Source Code to Create Weather App in PHP
&lt;/h2&gt;

&lt;p&gt;Following are the Source codes to create a Weather Application in PHP.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML Source Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;

  &amp;lt;!-- Bootstrap CSS --&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous"&amp;gt;

  &amp;lt;title&amp;gt;Weather App&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div class="container"&amp;gt;

          &amp;lt;h1&amp;gt;What's The Weather?&amp;lt;/h1&amp;gt;



          &amp;lt;form&amp;gt;
  &amp;lt;fieldset class="form-group"&amp;gt;
    &amp;lt;label for="city"&amp;gt;Enter the name of a city.&amp;lt;/label&amp;gt;
    &amp;lt;input type="text" class="form-control" name="city" id="city" placeholder="Eg. London, Tokyo" value = "&amp;lt;?php echo $_GET['city']; ?&amp;gt;"&amp;gt;
  &amp;lt;/fieldset&amp;gt;

  &amp;lt;button type="submit" class="btn btn-primary"&amp;gt;Submit&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;

          &amp;lt;div id="weather"&amp;gt;&amp;lt;?php

              if ($weather) {

                  echo '&amp;lt;div class="alert alert-success" role="alert"&amp;gt;
  '.$weather.'
&amp;lt;/div&amp;gt;';

              } else if ($error) {

                  echo '&amp;lt;div class="alert alert-danger" role="alert"&amp;gt;
  '.$error.'
&amp;lt;/div&amp;gt;';

              }

              ?&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;

    &amp;lt;!-- jQuery first, then Bootstrap JS. --&amp;gt;
    &amp;lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CSS Source Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;html { 
          background: url(background.jpeg) no-repeat center center fixed; 
          -webkit-background-size: cover;
          -moz-background-size: cover;
          -o-background-size: cover;
          background-size: cover;
          }

          body {

              background: none;

          }

          .container {

              text-align: center;
              margin-top: 100px;
              width: 450px;

          }

          input {

              margin: 20px 0;

          }

          #weather {

              margin-top:15px;

          }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  PHP Source Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

    $weather = "";
    $error = "";

    if ($_GET['city']) {

     $urlContents = file_get_contents("http://api.openweathermap.org/data/2.5/weather?q=".urlencode($_GET['city']).",uk&amp;amp;appid=4b6cbadba309b7554491c5dc66401886");

        $weatherArray = json_decode($urlContents, true);

        if ($weatherArray['cod'] == 200) {

            $weather = "The weather in ".$_GET['city']." is currently '".$weatherArray['weather'][0]['description']."'. ";

            $tempInCelcius = intval($weatherArray['main']['temp'] - 273);

            $weather .= " The temperature is ".$tempInCelcius."&amp;amp;deg;C and the wind speed is ".$weatherArray['wind']['speed']."m/s.";

        } else {

            $error = "Could not find city - please try again.";

        }

    }

?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>php</category>
      <category>api</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to Connect Contact form to email in PHP</title>
      <dc:creator>HMA WebDesign</dc:creator>
      <pubDate>Wed, 20 Mar 2024 17:30:21 +0000</pubDate>
      <link>https://dev.to/hmawebdesign/how-to-connect-contact-form-to-email-in-php-iao</link>
      <guid>https://dev.to/hmawebdesign/how-to-connect-contact-form-to-email-in-php-iao</guid>
      <description>&lt;p&gt;Here is a tutorial on how to receive email from HTML form using PHP. Here is a demo and tutorial on how to make the email recipient target land on your contact form. &lt;/p&gt;

&lt;p&gt;And how to connect a contact form to Receive Email from HTML Form using PHP and how to use the PHP mail() function.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Receive Email from HTML Form using PHP
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Video Tutorial&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/_bT-hcTsYhI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;There are a few steps to Receive Email from HTML Form using PHP and send the HTML form submission directly to an email address:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a contact form using HTML and CSS&lt;/li&gt;
&lt;li&gt;Host HTML form on the live web hosting server to write PHP script&lt;/li&gt;
&lt;li&gt;Open your VS Code editor&lt;/li&gt;
&lt;li&gt;Connect VS Code editor to live web server using FTP-Simple extension&lt;/li&gt;
&lt;li&gt;Change your file extension from .html to .php&lt;/li&gt;
&lt;li&gt;Write PHP code to send HTML form data to email using PHP&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Important Note:&lt;/em&gt;&lt;/strong&gt; First of all, host your contact form on any live web server in order to execute PHP code. And change your file extension to .php to run a PHP script.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML Source Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- connect with php file --&amp;gt;
&amp;lt;?php include 'mail.php'  ?&amp;gt;

&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
  &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
  &amp;lt;link rel="stylesheet" href="style.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;div class="container"&amp;gt;  
    &amp;lt;form id="contact" action="" method="post"&amp;gt;
      &amp;lt;h3&amp;gt;Contact Details&amp;lt;/h3&amp;gt;
      &amp;lt;h4&amp;gt;Contact us today, and get reply with in 24 hours!&amp;lt;/h4&amp;gt;
      &amp;lt;div class="row"&amp;gt;

        &amp;lt;div class="col"&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input placeholder="First Name" name="firstName" type="text" tabindex="1" required autofocus&amp;gt;
          &amp;lt;/fieldset&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input placeholder="Your Email Address" name="email" type="email" tabindex="2" required&amp;gt;
          &amp;lt;/fieldset&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input placeholder="Your Phone Number" name="tel" type="tel" tabindex="3" required&amp;gt;
          &amp;lt;/fieldset&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input placeholder="Date of birth" type="text" onfocus="(this.type='date')" name="date" tabindex="4" required&amp;gt;
          &amp;lt;/fieldset&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input type="text" name="city" placeholder="City/State Name" tabindex="5" required&amp;gt;
          &amp;lt;/fieldset&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;div class="col"&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input type="text" placeholder="Last Name" name="lastName"  tabindex="1" required autofocus&amp;gt;
          &amp;lt;/fieldset&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input type="text" name="address" placeholder="Home Address" tabindex="5" required&amp;gt;
          &amp;lt;/fieldset&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;p&amp;gt;What is your employment status?&amp;lt;/p&amp;gt;
            &amp;lt;div class="radio"&amp;gt;
              &amp;lt;input type="radio" id="job" name="status" value="job"&amp;gt;
              &amp;lt;label for="job"&amp;gt;Employed&amp;lt;/label&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="radio"&amp;gt; 
              &amp;lt;input type="radio" id="business" name="status" value="business"&amp;gt;
              &amp;lt;label for="business"&amp;gt;Business&amp;lt;/label&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div class="radio"&amp;gt;
              &amp;lt;input type="radio" id="student" name="status" value="student"&amp;gt;
              &amp;lt;label for="student"&amp;gt;Student&amp;lt;/label&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/fieldset&amp;gt;

         &amp;lt;!--  &amp;lt;fieldset&amp;gt;
            &amp;lt;label for="file"&amp;gt;Upload&amp;lt;/label&amp;gt;
            &amp;lt;input type="file" id="file" name="file"&amp;gt;
          &amp;lt;/fieldset&amp;gt; --&amp;gt;
        &amp;lt;/div&amp;gt;
     &amp;lt;/div&amp;gt;

        &amp;lt;!-- Error display --&amp;gt;
        &amp;lt;div&amp;gt;
         &amp;lt;p class="success"&amp;gt; &amp;lt;?php echo $success;  ?&amp;gt; &amp;lt;/p&amp;gt;
         &amp;lt;p class="failed"&amp;gt; &amp;lt;?php echo $failed;  ?&amp;gt; &amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;

      &amp;lt;fieldset&amp;gt;
        &amp;lt;button type="submit" name="submit" id="contact-submit" data-submit="...Sending"&amp;gt;Submit Now&amp;lt;/button&amp;gt;
      &amp;lt;/fieldset&amp;gt;
    &amp;lt;/form&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  CSS Source Code
&lt;/h2&gt;

&lt;p&gt;Now, you will get the source code for CSS (Cascading Style Sheet).&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@import url(https://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,600);

* {
    margin:0;
    padding:0;
    box-sizing:border-box;
    -webkit-box-sizing:border-box;
    -moz-box-sizing:border-box;
    -webkit-font-smoothing:antialiased;
    -moz-font-smoothing:antialiased;
    -o-font-smoothing:antialiased;
    text-rendering:optimizeLegibility;
}

body {
    font-family:"Open Sans", Helvetica, Arial, sans-serif;
    font-weight:400;
    font-size: 16px;
    line-height:30px;
    color:rgb(32, 32, 32);
    background: rgb(55, 170, 107);
}

.container {
    max-width:900px;
    width:100%;
    margin:0 auto;
    position:relative;
}

#contact input, textarea, button
{ font:400 16px "Open Sans", Helvetica, Arial, sans-serif; }

#contact {
    background:#e7e7e7;
    padding:25px;
    margin:50px 0;
}

#contact h3 {
    color: green;
    display: block;
    font-size: 30px;
    font-weight: 700;
    margin-left: 20px;
}

#contact h4 {
    margin:5px 0 15px;
    display:block;
    color: rgb(31, 31, 31);
    font-size:13px;
    margin-left: 20px;
}

fieldset {
    border: medium none !important;
    margin: 0 0 10px;
    min-width: 100%;
    padding: 0;
    width: 100%;
}

#contact input {
    width:100%;
    border:1px solid #CCC;
    background:#FFF;
    margin:0 0 5px;
    padding:10px;
}

#contact input:hover {
    -webkit-transition:border-color 0.3s ease-in-out;
    -moz-transition:border-color 0.3s ease-in-out;
    transition:border-color 0.3s ease-in-out;
    border:1px solid rgb(134, 134, 134);
}

#contact button {
    cursor:pointer;
    width: 20%;
    border:none;
    background:rgb(3, 153, 212);
    color:#FFF;
    margin:0 0 5px 20px;
    padding:10px;
    font-size:15px;
}

#contact button[type="submit"]:hover {
    background:#09C;
    -webkit-transition:background 0.3s ease-in-out;
    -moz-transition:background 0.3s ease-in-out;
    transition:background-color 0.3s ease-in-out;
}

#contact button[type="submit"]:active { box-shadow:inset 0 1px 3px rgba(0, 0, 0, 0.5); }

#contact input:focus {
    outline:0;
    border:1px solid rgb(112, 112, 112);
}
::-webkit-input-placeholder {
 color:rgb(66, 66, 66);
}


.row {
    display: flex;
    width: 100% !important;
}
.row .col {
    width: 50%;
    margin: 20px;
}

input[type="radio"] {
  width: 10% !important;
}

#contact .row .radio {
    border: 1px solid rgb(97, 97, 97) !important;
    background-color: rgb(255, 255, 255);
    margin-bottom: 5px !important;
}

.success{
    color: green;
    font-weight: 700;
    padding: 5px;
    text-align: center;
}
.failed{
    color: red;
    font-weight: 700;
    padding: 5px;
    text-align: center;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  PHP Source Code – How to Send HTML Form to Direct Mail?
&lt;/h2&gt;

&lt;p&gt;Following is the PHP Source code to get an email from an HTML form using PHP and send the HTML form to direct mail. Create a new mail.php file and paste the code inside it.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php  
if( isset($_POST['submit']) ) {
//getting user data
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$fromEmail = $_POST['email'];
$phone = $_POST['tel'];
$dateOfBirth = $_POST['date'];
$cityName = $_POST['city'];
$homeAddress = $_POST['address'];
$employmentStatus = $_POST['status'];

//Recipient email, Replace with your email Address
$mailTo = 'hmawebdesign@hotmail.com';

//email subject
$subject = ' A New Message Received From ' .$firstName;

//email message body
$htmlContent = '&amp;lt;h2&amp;gt; Email Request Received &amp;lt;/h2&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;Client Name: &amp;lt;/b&amp;gt; '.$firstName . " " . $lastName . '&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;Email: &amp;lt;/b&amp;gt; '.$fromEmail .'&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;Phone Number: &amp;lt;/b&amp;gt; '.$phone .'&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;Date of Birth: &amp;lt;/b&amp;gt; '.$dateOfBirth .'&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;City Name: &amp;lt;/b&amp;gt; '.$cityName .'&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;Home Address: &amp;lt;/b&amp;gt; '.$homeAddress .'&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;Employment Status: &amp;lt;/b&amp;gt; '.$employmentStatus .'&amp;lt;/p&amp;gt;';

//header for sender info
$headers = "From: " .$firstName . "&amp;lt;". $fromEmail . "&amp;gt;";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";

//PHP mailer function
 $result = mail($mailTo, $subject, $htmlContent, $headers);

   //error checking
   if($result) {
    $success = "The message was sent successfully!";
   } else {
    $failed = "Error: Message was not sent, Try again Later";
   }
}

?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Final Words&lt;/strong&gt;&lt;br&gt;
The tutorial explained how do I send an email from the client side using the PHP mailer function. If you find it helpful don’t forget to &lt;a href="https://www.youtube.com/channel/UCCj8edobyplMAnhwYvi9n4A?sub_confirmation=1"&gt;SUBSCRIBE to my YouTube Channel.&lt;/a&gt;&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://www.youtube.com/channel/UCCj8edobyplMAnhwYvi9n4A?sub_confirmation=1" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--KLeeHrPN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://yt3.googleusercontent.com/E5HXitBugzDnWzmPgIAsgLNPr5MBunby2fe2gjsOxHkXECPLyLQWgUlkRfM_PbPHd4Nx1GfT-Q%3Ds900-c-k-c0x00ffffff-no-rj" height="800" class="m-0" width="800"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://www.youtube.com/channel/UCCj8edobyplMAnhwYvi9n4A?sub_confirmation=1" rel="noopener noreferrer" class="c-link"&gt;
          
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Welcome to my channel, HMA WebDesign!
The purpose of this channel is to provide you a complete training course on Web development and freelancing techniques. This channel will teach you  WordPress Website, eCommerce Website, Custom CMS, Error Fix, Usability Test, Performance Optimization, Security, and SEO.

Blog Website: https://www.hmawebdesign.com/
Please subscribe to our channel for learning and earning money online!

-------------------------------------------------------------------
Contact me through social media for web development work:

-  witter:          https://twitter.com/HmaWebdesign
- Facebook:    https://web.facebook.com/HmaWebdesign
- LinkedIn:      https://www.linkedin.com/hmawebdesign/
- Instagram     https://www.instagram.com/hmawebdesign/

        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://res.cloudinary.com/practicaldev/image/fetch/s--QIiCHmfA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.youtube.com/s/desktop/4feff1e2/img/favicon.ico" width="16" height="16"&gt;
        youtube.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>php</category>
      <category>html</category>
      <category>coding</category>
    </item>
    <item>
      <title>How to Receive Email from HTML Form using PHP</title>
      <dc:creator>HMA WebDesign</dc:creator>
      <pubDate>Tue, 19 Mar 2024 07:33:54 +0000</pubDate>
      <link>https://dev.to/hmawebdesign/how-to-receive-email-from-html-form-using-php-how-to-connect-contact-form-to-email-in-php-10fl</link>
      <guid>https://dev.to/hmawebdesign/how-to-receive-email-from-html-form-using-php-how-to-connect-contact-form-to-email-in-php-10fl</guid>
      <description>&lt;p&gt;Here is a tutorial on how to receive email from HTML form using PHP. Here is a demo and tutorial on how to make the email recipient target land on your contact form. And how to connect a contact form to Receive Email from HTML Form using PHP and how to use the PHP mail() function.&lt;/p&gt;

&lt;p&gt;PHP Mail is most often used by website mods and admins because it is cheap, fast, and easy to set up. Many UK businesses prefer PHP Mail because it can be configured to help with SEO as well as marketing automation.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Receive Email from HTML Form using PHP
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/_bT-hcTsYhI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There are a few steps to Receive Email from HTML Form using PHP and send the HTML form submission directly to an email address&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a contact form using HTML and CSS&lt;/li&gt;
&lt;li&gt;Host HTML form on the live web hosting server to write PHP script&lt;/li&gt;
&lt;li&gt;Open your VS Code editor&lt;/li&gt;
&lt;li&gt;Connect VS Code editor to live web server using FTP-Simple extension&lt;/li&gt;
&lt;li&gt;Change your file extension from .html to .php&lt;/li&gt;
&lt;li&gt;Write PHP code to send HTML form data to email using PHP&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;_Important Note: _&lt;/strong&gt;First of all, host your contact form on any live web server in order to execute PHP code. And change your file extension to .php to run a PHP script.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML Contact Form Source Code
&lt;/h2&gt;

&lt;p&gt;Now I am going to provide you the source codes of HTML, CSS, and PHP for the contact form. I have created a separate sentMail.php file to write the PHP script. And add this PHP file with the HTML code of the contact form using the PHP include statement.&lt;/p&gt;

&lt;p&gt;Below is the HTML source code of the contact form to send the form details to an email address. This contact form contains the following user data fields.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User name&lt;/li&gt;
&lt;li&gt;User email address&lt;/li&gt;
&lt;li&gt;Phone number of the customer&lt;/li&gt;
&lt;li&gt;Home Address&lt;/li&gt;
&lt;li&gt;User Date of birth.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- connect with php file --&amp;gt;
&amp;lt;?php include 'mail.php'  ?&amp;gt;

&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
  &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
  &amp;lt;link rel="stylesheet" href="style.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;div class="container"&amp;gt;  
    &amp;lt;form id="contact" action="" method="post"&amp;gt;
      &amp;lt;h3&amp;gt;Contact Details&amp;lt;/h3&amp;gt;
      &amp;lt;h4&amp;gt;Contact us today, and get reply with in 24 hours!&amp;lt;/h4&amp;gt;
      &amp;lt;div class="row"&amp;gt;

        &amp;lt;div class="col"&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input placeholder="First Name" name="firstName" type="text" tabindex="1" required autofocus&amp;gt;
          &amp;lt;/fieldset&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input placeholder="Your Email Address" name="email" type="email" tabindex="2" required&amp;gt;
          &amp;lt;/fieldset&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input placeholder="Your Phone Number" name="tel" type="tel" tabindex="3" required&amp;gt;
          &amp;lt;/fieldset&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input placeholder="Date of birth" type="text" onfocus="(this.type='date')" name="date" tabindex="4" required&amp;gt;
          &amp;lt;/fieldset&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input type="text" name="city" placeholder="City/State Name" tabindex="5" required&amp;gt;
          &amp;lt;/fieldset&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;div class="col"&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input type="text" placeholder="Last Name" name="lastName"  tabindex="1" required autofocus&amp;gt;
          &amp;lt;/fieldset&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;input type="text" name="address" placeholder="Home Address" tabindex="5" required&amp;gt;
          &amp;lt;/fieldset&amp;gt;
          &amp;lt;fieldset&amp;gt;
            &amp;lt;p&amp;gt;What is your employment status?&amp;lt;/p&amp;gt;
            &amp;lt;div class="radio"&amp;gt;
              &amp;lt;input type="radio" id="job" name="status" value="job"&amp;gt;
              &amp;lt;label for="job"&amp;gt;Employed&amp;lt;/label&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="radio"&amp;gt; 
              &amp;lt;input type="radio" id="business" name="status" value="business"&amp;gt;
              &amp;lt;label for="business"&amp;gt;Business&amp;lt;/label&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div class="radio"&amp;gt;
              &amp;lt;input type="radio" id="student" name="status" value="student"&amp;gt;
              &amp;lt;label for="student"&amp;gt;Student&amp;lt;/label&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/fieldset&amp;gt;

         &amp;lt;!--  &amp;lt;fieldset&amp;gt;
            &amp;lt;label for="file"&amp;gt;Upload&amp;lt;/label&amp;gt;
            &amp;lt;input type="file" id="file" name="file"&amp;gt;
          &amp;lt;/fieldset&amp;gt; --&amp;gt;
        &amp;lt;/div&amp;gt;
     &amp;lt;/div&amp;gt;

        &amp;lt;!-- Error display --&amp;gt;
        &amp;lt;div&amp;gt;
         &amp;lt;p class="success"&amp;gt; &amp;lt;?php echo $success;  ?&amp;gt; &amp;lt;/p&amp;gt;
         &amp;lt;p class="failed"&amp;gt; &amp;lt;?php echo $failed;  ?&amp;gt; &amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;

      &amp;lt;fieldset&amp;gt;
        &amp;lt;button type="submit" name="submit" id="contact-submit" data-submit="...Sending"&amp;gt;Submit Now&amp;lt;/button&amp;gt;
      &amp;lt;/fieldset&amp;gt;
    &amp;lt;/form&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CSS Source Code
&lt;/h2&gt;

&lt;p&gt;Now, you will get the source code for CSS (Cascading Style Sheet)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@import url(https://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,600);

* {
    margin:0;
    padding:0;
    box-sizing:border-box;
    -webkit-box-sizing:border-box;
    -moz-box-sizing:border-box;
    -webkit-font-smoothing:antialiased;
    -moz-font-smoothing:antialiased;
    -o-font-smoothing:antialiased;
    text-rendering:optimizeLegibility;
}

body {
    font-family:"Open Sans", Helvetica, Arial, sans-serif;
    font-weight:400;
    font-size: 16px;
    line-height:30px;
    color:rgb(32, 32, 32);
    background: rgb(55, 170, 107);
}

.container {
    max-width:900px;
    width:100%;
    margin:0 auto;
    position:relative;
}

#contact input, textarea, button
{ font:400 16px "Open Sans", Helvetica, Arial, sans-serif; }

#contact {
    background:#e7e7e7;
    padding:25px;
    margin:50px 0;
}

#contact h3 {
    color: green;
    display: block;
    font-size: 30px;
    font-weight: 700;
    margin-left: 20px;
}

#contact h4 {
    margin:5px 0 15px;
    display:block;
    color: rgb(31, 31, 31);
    font-size:13px;
    margin-left: 20px;
}

fieldset {
    border: medium none !important;
    margin: 0 0 10px;
    min-width: 100%;
    padding: 0;
    width: 100%;
}

#contact input {
    width:100%;
    border:1px solid #CCC;
    background:#FFF;
    margin:0 0 5px;
    padding:10px;
}

#contact input:hover {
    -webkit-transition:border-color 0.3s ease-in-out;
    -moz-transition:border-color 0.3s ease-in-out;
    transition:border-color 0.3s ease-in-out;
    border:1px solid rgb(134, 134, 134);
}

#contact button {
    cursor:pointer;
    width: 20%;
    border:none;
    background:rgb(3, 153, 212);
    color:#FFF;
    margin:0 0 5px 20px;
    padding:10px;
    font-size:15px;
}

#contact button[type="submit"]:hover {
    background:#09C;
    -webkit-transition:background 0.3s ease-in-out;
    -moz-transition:background 0.3s ease-in-out;
    transition:background-color 0.3s ease-in-out;
}

#contact button[type="submit"]:active { box-shadow:inset 0 1px 3px rgba(0, 0, 0, 0.5); }

#contact input:focus {
    outline:0;
    border:1px solid rgb(112, 112, 112);
}
::-webkit-input-placeholder {
 color:rgb(66, 66, 66);
}


.row {
    display: flex;
    width: 100% !important;
}
.row .col {
    width: 50%;
    margin: 20px;
}

input[type="radio"] {
  width: 10% !important;
}

#contact .row .radio {
    border: 1px solid rgb(97, 97, 97) !important;
    background-color: rgb(255, 255, 255);
    margin-bottom: 5px !important;
}

.success{
    color: green;
    font-weight: 700;
    padding: 5px;
    text-align: center;
}
.failed{
    color: red;
    font-weight: 700;
    padding: 5px;
    text-align: center;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  PHP Source Code – How to Send HTML Form to Direct Mail?
&lt;/h2&gt;

&lt;p&gt;Following is the PHP Source code to get an email from an HTML form using PHP and send the HTML form to direct mail. Create a new mail.php file and paste the code inside it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php  
if( isset($_POST['submit']) ) {
//getting user data
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$fromEmail = $_POST['email'];
$phone = $_POST['tel'];
$dateOfBirth = $_POST['date'];
$cityName = $_POST['city'];
$homeAddress = $_POST['address'];
$employmentStatus = $_POST['status'];

//Recipient email, Replace with your email Address
$mailTo = 'hmawebdesign@hotmail.com';

//email subject
$subject = ' A New Message Received From ' .$firstName;

//email message body
$htmlContent = '&amp;lt;h2&amp;gt; Email Request Received &amp;lt;/h2&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;Client Name: &amp;lt;/b&amp;gt; '.$firstName . " " . $lastName . '&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;Email: &amp;lt;/b&amp;gt; '.$fromEmail .'&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;Phone Number: &amp;lt;/b&amp;gt; '.$phone .'&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;Date of Birth: &amp;lt;/b&amp;gt; '.$dateOfBirth .'&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;City Name: &amp;lt;/b&amp;gt; '.$cityName .'&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;Home Address: &amp;lt;/b&amp;gt; '.$homeAddress .'&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;Employment Status: &amp;lt;/b&amp;gt; '.$employmentStatus .'&amp;lt;/p&amp;gt;';

//header for sender info
$headers = "From: " .$firstName . "&amp;lt;". $fromEmail . "&amp;gt;";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";

//PHP mailer function
 $result = mail($mailTo, $subject, $htmlContent, $headers);

   //error checking
   if($result) {
    $success = "The message was sent successfully!";
   } else {
    $failed = "Error: Message was not sent, Try again Later";
   }
}

?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Final Words&lt;/strong&gt;&lt;br&gt;
The tutorial explained how do I send an email from the client side using the PHP mailer function. If you feel any difficulty understanding this post, you can ask in the comment section below. Your suggestion and queries are always welcome. If you find it helpful don’t forget to &lt;a href="https://www.youtube.com/channel/UCCj8edobyplMAnhwYvi9n4A?sub_confirmation=1"&gt;SUBSCRIBE to my YouTube Channel.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>php</category>
      <category>programming</category>
      <category>career</category>
    </item>
    <item>
      <title>How to Create PHP Send Email Contact Form with Attachment</title>
      <dc:creator>HMA WebDesign</dc:creator>
      <pubDate>Tue, 19 Mar 2024 06:58:26 +0000</pubDate>
      <link>https://dev.to/hmawebdesign/how-to-create-php-send-email-contact-form-with-attachment-43ka</link>
      <guid>https://dev.to/hmawebdesign/how-to-create-php-send-email-contact-form-with-attachment-43ka</guid>
      <description>&lt;p&gt;We are going to create aPHP Send Email Contact Form with Attachment option which will send an email to a specific email address on form submission. &lt;/p&gt;

&lt;p&gt;I divided the code into three parts for better understanding. We will put the HTML code in the first part, then the CSS code in the second file, and at the end, we will put the PHP code.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How do I create a PHP form email with an attachment?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Follow these steps to Send an Email with an attachment on Form Submission using PHP:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build a simple HTML contact form (with optional CSS) and embed it on your website.&lt;/li&gt;
&lt;li&gt;Host your contact form to any internet web hosting server.&lt;/li&gt;
&lt;li&gt;Connect your code editor to a remote server to edit the PHP script.&lt;/li&gt;
&lt;li&gt;Write a PHP script that will effectively handle sending emails.&lt;/li&gt;
&lt;li&gt;Get the submitted form data using $_POST in PHP.&lt;/li&gt;
&lt;li&gt;Validate form data to check whether the mandatory fields are not empty.&lt;/li&gt;
&lt;li&gt;Validate email address using FILTER_VALIDATE_EMAIL in PHP.&lt;/li&gt;
&lt;li&gt;Check the file extension to allow certain file formats (PDF, Image, and MS Word files)&lt;/li&gt;
&lt;li&gt;Send an autoresponder to a user, letting them know we’ll handle their request
.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Video Tutorial (Step-by-Step Process)
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/YNJtwMJSySI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Source Codes
&lt;/h2&gt;

&lt;p&gt;Now you will get the source codes to create PHP Send Email Contact Form with attachment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML Contact Form (Source Code)&lt;/strong&gt;&lt;br&gt;
First of all, Create a new file index.php and paste the given HTML contact form code there!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php include 'mail.php' ?&amp;gt;

&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;
 &amp;lt;meta charset="UTF-8"&amp;gt;
 &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
 &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;

 &amp;lt;!-- Linking CSS file --&amp;gt;
 &amp;lt;link rel="stylesheet" href="style.css"&amp;gt;
 &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
 &amp;lt;div class="container"&amp;gt;


  &amp;lt;form method="post" class="form" enctype="multipart/form-data"&amp;gt;
   &amp;lt;div class="heading"&amp;gt;
    &amp;lt;h2&amp;gt;Contact Form
     &amp;lt;h2 /&amp;gt;
   &amp;lt;/div&amp;gt;

   &amp;lt;div class="formGroup"&amp;gt;
    &amp;lt;input type="text" name="name" id="name" placeholder="Name" autocomplete="off" value="&amp;lt;?php echo !empty($postData['name']) ? $postData['name'] : ''; ?&amp;gt;" required=""&amp;gt;
   &amp;lt;/div&amp;gt;

   &amp;lt;div class="formGroup"&amp;gt;
    &amp;lt;input type="email" name="email" id="email" placeholder="Email ID" autocomplete="off" value="&amp;lt;?php echo !empty($postData['email']) ? $postData['email'] : ''; ?&amp;gt;" required=""&amp;gt;
   &amp;lt;/div&amp;gt;

   &amp;lt;div class="formGroup"&amp;gt;
    &amp;lt;input type="text" name="subject" placeholder="Subject" autocomplete="off" value="&amp;lt;?php echo !empty($postData['subject']) ? $postData['subject'] : ''; ?&amp;gt;" required=""&amp;gt;
   &amp;lt;/div&amp;gt;

   &amp;lt;div class="formGroup"&amp;gt;
    &amp;lt;input type="text" name="message" placeholder="Your Message" autocomplete="off" &amp;lt;?php echo !empty($postData['message']) ? $postData['message'] : ''; ?&amp;gt; required=""&amp;gt;
   &amp;lt;/div&amp;gt;

   &amp;lt;div class="formGroup"&amp;gt;
    &amp;lt;input type="file" name="attachment" class="form-control" multiple&amp;gt;
   &amp;lt;/div&amp;gt;

   &amp;lt;!-- Display submission status --&amp;gt;
   &amp;lt;div class="status"&amp;gt;
    &amp;lt;?php if (!empty($statusMsg)) { ?&amp;gt;
     &amp;lt;p class="statusMsg &amp;lt;?php echo !empty($msgClass) ? $msgClass : ''; ?&amp;gt;"&amp;gt;
      &amp;lt;?php echo $statusMsg; ?&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;?php } ?&amp;gt;
   &amp;lt;/div&amp;gt;

   &amp;lt;div class="formGroup"&amp;gt;
    &amp;lt;button class="btn2" name="submit" value="SUBMIT" type="submit"&amp;gt;SUBMIT &amp;lt;/button&amp;gt;
   &amp;lt;/div&amp;gt;

   &amp;lt;form /&amp;gt;
 &amp;lt;/div&amp;gt;

&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CSS Source Code
&lt;/h2&gt;

&lt;p&gt;Next, create a new style.css file and paste the below CSS contact form code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
/* adding background image */
body{
  font-family: Arial, Helvetica, sans-serif;
}
/* Center content vertically and horizontally */
.container{
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}
.form{
  width: 350px;
  height: 460px;
  background-color: white;
  box-shadow: 0 5px 30px black;
}
.heading h2{
  padding: 3px;
  margin: 30px 0px 10px 30px;
  border-style: none;
  background-color: transparent;
  color: black;
  font-size: 20px;
  font-weight: 600;
}
.formGroup{
  display: flex;
  justify-content: center;
}
.formGroup input{
  border: none;
  width: 80%;
  padding: 7px;
  margin-bottom: 15px;
  background-color: transparent;
  border-bottom: 2px solid rgb(68, 68, 68);
  color: black;
  font-weight: bold;
  font-size: 14px;
}

input:focus{
  outline: none;
  font-size: 17px;
  background-color: transparent;
}
.text{
  color: rgb(42, 41, 41);
  font-size: 13px;
}
.btn2{
  padding: 10px;
  outline: none;
  width: 150px;
  border-radius: 20px;
  border-style: none;
  background-color: rgb(28, 131, 28);
  color: whitesmoke;
  font-weight: 600;
  margin-top: 10px;
}
.btn2:hover {
 background-color: rgb(1, 63, 1);
}
.status {
 color: green;
 text-align: center;
 margin: 5px;
 font-weight: 600;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  PHP Contact Form Send Email (Source Code)
&lt;/h2&gt;

&lt;p&gt;Finally below is the PHP code script of the HTML contact form to send contact form data to email.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
$postData = $uploadedFile = $statusMsg = '';
$msgClass = 'errordiv';
if(isset($_POST['submit'])){
    // Get the submitted form data
    $postData = $_POST;
    $email = $_POST['email'];
    $name = $_POST['name'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];

    // Check whether submitted data is not empty
    if(!empty($email) &amp;amp;&amp;amp; !empty($name) &amp;amp;&amp;amp; !empty($subject) &amp;amp;&amp;amp; !empty($message)){

        // Validate email
        if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){
            $statusMsg = 'Please enter your valid email.';
        }else{
            $uploadStatus = 1;

            // Upload attachment file
            if(!empty($_FILES["attachment"]["name"])){

                // File path config
                $targetDir = "uploads/";
                $fileName = basename($_FILES["attachment"]["name"]);
                $targetFilePath = $targetDir . $fileName;
                $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);

                // Allow certain file formats
                $allowTypes = array('pdf', 'doc', 'docx', 'jpg', 'png', 'jpeg');
                if(in_array($fileType, $allowTypes)){
                    // Upload file to the server
                    if(move_uploaded_file($_FILES["attachment"]["tmp_name"], $targetFilePath)){
                        $uploadedFile = $targetFilePath;
                    }else{
                        $uploadStatus = 0;
                        $statusMsg = "Sorry, there was an error uploading your file.";
                    }
                }else{
                    $uploadStatus = 0;
                    $statusMsg = 'Sorry, only PDF, DOC, JPG, JPEG, &amp;amp; PNG files are allowed to upload.';
                }
            }

            if($uploadStatus == 1){

                // Recipient Email, write your email here
                $toEmail = 'YourEmail@email.com';

                // Sender Data
                $from = $email;
                $fromName = $name;

                // Subject
                $emailSubject = 'Contact Request Submitted by '.$name;

                // Message 
                $htmlContent = '&amp;lt;h2&amp;gt;Customer Contact Detail!&amp;lt;/h2&amp;gt;
                    &amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Name:&amp;lt;/b&amp;gt; '.$name.'&amp;lt;/p&amp;gt;
                    &amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Email:&amp;lt;/b&amp;gt; '.$email.'&amp;lt;/p&amp;gt;
                    &amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Subject:&amp;lt;/b&amp;gt; '.$subject.'&amp;lt;/p&amp;gt;
                    &amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Message:&amp;lt;/b&amp;gt; '.$message.'&amp;lt;/p&amp;gt;';

                // Header for sender info
                $headers = "From:". $fromName." &amp;lt;".$from."&amp;gt;";

                if(!empty($uploadedFile) &amp;amp;&amp;amp; file_exists($uploadedFile)){

                    // Boundary 
                    $semi_rand = md5(time()); 
                    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 

                    // Headers for attachment 
                    $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; 

                    // Multipart boundary 
                    $message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" .
                    "Content-Transfer-Encoding: 7bit\n\n" . $htmlContent . "\n\n"; 

                    // Preparing attachment
                    if(is_file($uploadedFile)){
                        $message .= "--{$mime_boundary}\n";
                        $fp =    @fopen($uploadedFile,"rb");
                        $data =  @fread($fp,filesize($uploadedFile));
                        @fclose($fp);
                        $data = chunk_split(base64_encode($data));
                        $message .= "Content-Type: application/octet-stream; name=\"".basename($uploadedFile)."\"\n" . 
                        "Content-Description: ".basename($uploadedFile)."\n" .
                        "Content-Disposition: attachment;\n" . " filename=\"".basename($uploadedFile)."\"; size=".filesize($uploadedFile).";\n" . 
                        "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
                    }

                    $message .= "--{$mime_boundary}--";
                    $returnpath = "-f" . $email;

                    // Send email
                    $mail = mail($toEmail, $emailSubject, $message, $headers, $returnpath);

                    // Delete attachment file from the server
                    @unlink($uploadedFile);
                }else{
                     // Set content-type header for sending HTML email
                    $headers .= "\r\n". "MIME-Version: 1.0";
                    $headers .= "\r\n". "Content-type:text/html;charset=UTF-8";

                    // Send email
                    $mail = mail($toEmail, $emailSubject, $htmlContent, $headers); 
                }

                // If mail sent
                if($mail){
                    $statusMsg = 'Your Message was submitted successfully!';
                    $msgClass = 'succdiv';

                    $postData = '';
                }else{
                    $statusMsg = 'Your contact request submission failed, please try again.';
                }
            }
        }
    }else{
        $statusMsg = 'Please fill all the fields.';
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Final Words&lt;br&gt;
This blog article explained to you, how to create a working user form using PHP with an attachment function and send an email from the client side using the PHP mailer function. If you feel any difficulty understanding this post, you can ask in the comment section below. Your suggestion and queries are always welcome. If you find it helpful don’t forget to &lt;a href="https://www.youtube.com/channel/UCCj8edobyplMAnhwYvi9n4A?sub_confirmation=1"&gt;SUBSCRIBE to my YouTube&lt;/a&gt; Channel.&lt;/p&gt;

</description>
      <category>php</category>
      <category>html</category>
      <category>coding</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Create a Registration Form in PHP and MySQL</title>
      <dc:creator>HMA WebDesign</dc:creator>
      <pubDate>Tue, 19 Mar 2024 06:13:03 +0000</pubDate>
      <link>https://dev.to/hmawebdesign/how-to-create-a-registration-form-in-php-and-mysql-3h9o</link>
      <guid>https://dev.to/hmawebdesign/how-to-create-a-registration-form-in-php-and-mysql-3h9o</guid>
      <description>&lt;h2&gt;
  
  
  How to Create a Registration Form in PHP
&lt;/h2&gt;

&lt;p&gt;Follow these steps to learn How to Create a Registration Form in PHP and MySQL in 2023.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Setting up the Environment&lt;/li&gt;
&lt;li&gt;Create a new database in PHPMyAdmin on localhost&lt;/li&gt;
&lt;li&gt;Setting up the database&lt;/li&gt;
&lt;li&gt;Create a simple HTML form&lt;/li&gt;
&lt;li&gt;PHP validation and submission&lt;/li&gt;
&lt;li&gt;Storing user data in MySQL database&lt;/li&gt;
&lt;li&gt;Write PHP code for the user registration form&lt;/li&gt;
&lt;li&gt;Successful user 
registration confirmation. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can also watch the video tutorial for the step-by-step process of creating a new database on localhost. Also, learn How to Create a Registration Form in PHP and MySQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Video Tutorial – How to Create a Registration Form in PHP
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/b5ruAhqU17o"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the Database
&lt;/h2&gt;

&lt;p&gt;The first step in creating a user registration form is to set up a database to store user information. To do this, we’ll use MySQL, a popular relational database management system. Here’s a sample SQL query for creating a table to store user information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE users (
  id INT(11) AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(50) NOT NULL UNIQUE,
  email VARCHAR(50) NOT NULL UNIQUE,
  password CHAR(60) NOT NULL
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This query creates a table called “users” with four columns: an auto-incrementing “id” column that serves as the primary key, a “username” column for storing the user’s chosen username, an “email” column for storing the user’s email address, and a “password” column for storing the user’s hashed password.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the HTML Form
&lt;/h2&gt;

&lt;p&gt;The next step is to design the user interface of the registration form. You can use HTML to create the form and CSS to style it. Make sure that the form is user-friendly and easy to navigate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php include('register.php'); ?&amp;gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
    &amp;lt;title&amp;gt;User Registration Form&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
        body {
            background-color: #eeeeee;
            font-family: Arial, sans-serif;
            padding: 80px;
        }
        form {
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0px 0px 10px #ccc;
            padding: 20px;
            width: 350px;
            margin: 0 auto;
        }
        input[type=text],
        input[type=password],
        input[type=email] {
            width: 100%;
            padding: 12px 20px;
            margin: 8px 0;
            display: inline-block;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
        }
        button[type=submit] {
            background-color: #4CAF50;
            color: white;
            padding: 14px 20px;
            margin: 8px 0;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            width: 100%;
        }
        button[type=submit]:hover {
            background-color: #45a049;
        }
        #successMessage {
            color: green;
            font-size: 15px;
            margin: 10px;
        }
        #errorMessage {
            color: red;
            font-size: 15px;
            margin: 10px;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;form method="POST"&amp;gt;
        &amp;lt;h2&amp;gt;User Registration Form&amp;lt;/h2&amp;gt;
        &amp;lt;label for="username"&amp;gt;Username:&amp;lt;/label&amp;gt;
        &amp;lt;input type="text" id="username" name="username" required&amp;gt;
        &amp;lt;label for="email"&amp;gt;Email:&amp;lt;/label&amp;gt;
        &amp;lt;input type="email" id="email" name="email" required&amp;gt;
        &amp;lt;label for="password"&amp;gt;Password:&amp;lt;/label&amp;gt;
        &amp;lt;input type="password" id="password" name="password" required&amp;gt;
        &amp;lt;!-- Display success and error messages --&amp;gt;
        &amp;lt;div id="errorMessage"&amp;gt; &amp;lt;?php echo $error  ?&amp;gt; &amp;lt;/div&amp;gt;
        &amp;lt;div id="successMessage"&amp;gt; &amp;lt;?php echo $success  ?&amp;gt; &amp;lt;/div&amp;gt;
        &amp;lt;button type="submit" name="button"&amp;gt;Register&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  PHP Validation and Submission
&lt;/h2&gt;

&lt;p&gt;Now that we have a form that collects user information, we need to create a PHP script that validates the submitted data and inserts it into the MySQL database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Validating User Input
&lt;/h2&gt;

&lt;p&gt;After designing the form, it’s important to validate user input. Server-side validation ensures that user input is correct and meets the required criteria. In PHP, you can use the “filter_input()” function to validate user input.&lt;/p&gt;

&lt;p&gt;PHP code for validating user input should be added before inserting the data into the database. You can also display error messages to guide users in filling out the form correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Storing User Data in MySQL
&lt;/h2&gt;

&lt;p&gt;Once the user input is validated, the next step is to store user data in a MySQL database. To do this, create a PHP file to connect to MySQL and insert user data into the database. You can use the “mysqli” function in PHP to connect to the MySQL database.&lt;/p&gt;

&lt;h2&gt;
  
  
  User Registration – PHP Code
&lt;/h2&gt;

&lt;p&gt;Here’s an example of what the PHP script might look like: Create a new PHP file name register.php and paste the below code inside this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
// Connect to the MySQL database
$success = "";
$error = "";
if (array_key_exists("button", $_POST)) {
$mysqli = new mysqli("localhost", "root", "", " Your Database name");
// Check for errors
if ($mysqli-&amp;gt;connect_error) {
die("Connection failed: " . $mysqli-&amp;gt;connect_error);
} else { 
  // Validate the submitted data
  $username = $_POST["username"];
  $email = $_POST["email"];
  $password = password_hash($_POST["password"], PASSWORD_DEFAULT);
  // Check if the username or email already exists in the database
  $result = $mysqli-&amp;gt;query("SELECT * FROM users WHERE username='$username' OR email='$email'");
  if ($result-&amp;gt;num_rows &amp;gt; 0) {
      $error = "Username or email already taken.";
  } else {
    // Insert the user's information into the database
    $mysqli-&amp;gt;query("INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$password')");

    //success message
      $success = "Data submitted Successfully";
  }
}
}
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In this blog post, we have shown you how to create a registration form in PHP and MySQL. Following these steps, you can easily collect user data and store it securely in a database. Registration forms are an essential component of any website that requires users to create accounts or sign up for a service. So, start creating your registration form today and start collecting user data!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>php</category>
      <category>mysql</category>
      <category>backend</category>
    </item>
    <item>
      <title>How To Attach Multiple Files in PHPMailer Email Using PHP</title>
      <dc:creator>HMA WebDesign</dc:creator>
      <pubDate>Mon, 18 Mar 2024 17:39:14 +0000</pubDate>
      <link>https://dev.to/hmawebdesign/how-to-attach-multiple-files-in-phpmailer-email-using-php-2mio</link>
      <guid>https://dev.to/hmawebdesign/how-to-attach-multiple-files-in-phpmailer-email-using-php-2mio</guid>
      <description>&lt;h2&gt;
  
  
  What is PHP Mailer?
&lt;/h2&gt;

&lt;p&gt;Before we dive into the details, let’s briefly introduce PHP Mailer. PHP Mailer is a robust PHP library that simplifies the process of sending emails through PHP scripts. It offers an intuitive and feature-rich interface for sending plain text and HTML emails, complete with attachments and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps – Send HTML Form via PHP Mailer
&lt;/h2&gt;

&lt;p&gt;Let’s start with a detailed outline that will guide us to Send HTML Form via PHP Mailer through this extensive guide. Here are the important steps to Send an HTML Form via PHP Mailer on HTML form submission:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download and install PHP Mailer from GitHub&lt;/li&gt;
&lt;li&gt;Setup your HTML Contact Form&lt;/li&gt;
&lt;li&gt;Include PHP Mailer in your HTML code&lt;/li&gt;
&lt;li&gt;Configure PHP Mailer&lt;/li&gt;
&lt;li&gt;Process form data to send email&lt;/li&gt;
&lt;li&gt;Compose the Email&lt;/li&gt;
&lt;li&gt;Handle Success and Error messages&lt;/li&gt;
&lt;li&gt;Send the Email&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Video Tutorial – Send HTML Form via PHP Mailer
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/r5KSwOo-V-A"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Now that we have our roadmap, let’s explore each section in detail to Send HTML Forms via PHP Mailer.&lt;br&gt;
&lt;strong&gt;How to Send HTML Form to Email Using PHP Mailer&lt;/strong&gt;&lt;br&gt;
Sending HTML forms via email is a seamless process when you have PHP Mailer at your disposal. Here’s a step-by-step guide to achieving.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;br&gt;
Before diving into implementation, ensure that you have the following prerequisites in place:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Web Server with PHP Support:&lt;/strong&gt; You’ll need a web server, such as Apache or Google, with PHP support to run your PHP Mailer script.&lt;/p&gt;

&lt;p&gt;Email Server Access: Ensure you have access to an email server or SMTP server to send emails, such as Gmail.&lt;br&gt;
Basic HTML and PHP Knowledge: Familiarize yourself with HTML to create the form and PHP to process it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Let’s start by downloading PHP Mailer and setting up our HTML form to Send HTML Form via PHP Mailer:&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Download and install PHP Mailer
&lt;/h2&gt;

&lt;p&gt;Begin by downloading the PHP Mailer library. You can obtain it from the official GitHub repository or use Composer if you prefer package management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Download the PHP Mailer manually from the GitHub library &lt;a href="https://github.com/PHPMailer/PHPMailer"&gt;Click Here&lt;/a&gt;!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you want to install the PHPMailer using Composer. First of all, simply install the &lt;a href="https://getcomposer.org/"&gt;Composer Setup&lt;/a&gt; on your computer and run the following command in your terminal:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;composer require phpmailer/phpmailer&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Alternatively, if you’re not using Composer, you can &lt;a href="https://github.com/PHPMailer/PHPMailer/archive/master.zip"&gt;download PHPMailer&lt;/a&gt; as a zip file, and then copy the contents of the PHPMailer folder into one of the include_path directories specified in your PHP configuration and load each class file manually:&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Set Up Your HTML Form
&lt;/h2&gt;

&lt;p&gt;Create an HTML form on your website where users can submit their information. Ensure that your form fields have appropriate name attributes.&lt;/p&gt;
&lt;h2&gt;
  
  
  Configure PHP Mailer
&lt;/h2&gt;

&lt;p&gt;Set up PHP Mailer with your email server details, including the SMTP host, username, password, and port. Make sure to use valid credentials and a secure connection.&lt;/p&gt;

&lt;p&gt;If you are using a Gmail SMTP server, first of all, login to your Gmail ID, turn on 2-step authentication and, generate an App Password. To generate an App Password in your Gmail account &lt;a href="https://myaccount.google.com/apppasswords"&gt;follow this link&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  HTML Form Source Code
&lt;/h2&gt;

&lt;p&gt;I have created a simple HTML form to send web form data to email using PHPMailer. I will collect this form data from the user and send it to my email address using PHPMailer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
  &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
  &amp;lt;style&amp;gt;
    @import url(https://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,600);

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-weight: 300;
      font-size: 12px;
      line-height: 30px;
      color: #272727;
      background: rgb(25, 199, 155);
    }

    .container {
      max-width: 400px;
      width: 100%;
      margin: 0 auto;
      position: relative;
    }

    #contact input {
      font: 400 12px/16px;
      width: 100%;
      border: 1px solid #CCC;
      background: #FFF;
      margin: 10 5px;
      padding: 10px;
    }

    h1 {
      margin-bottom: 30px;
      font-size: 30px;
    }

    #contact {
      background: #F9F9F9;
      padding: 25px;
      margin: 50px 0;
    }


    fieldset {
      border: medium none !important;
      margin: 0 0 10px;
      min-width: 100%;
      padding: 0;
      width: 100%;
    }

    textarea {
      height: 100px;
      max-width: 100%;
      resize: none;
      width: 100%;
    }

    button {
      cursor: pointer;
      width: 100%;
      border: none;
      background: rgb(17, 146, 60);
      color: #FFF;
      margin: 0 0 5px;
      padding: 10px;
      font-size: 20px;
    }

    button:hover {
      background-color: rgb(15, 95, 42);
    }
  &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
  &amp;lt;div class="container"&amp;gt;
    &amp;lt;form id="contact" action="mail.php" method="post" enctype="multipart/form-data"&amp;gt;
      &amp;lt;h1&amp;gt;Contact Form&amp;lt;/h1&amp;gt;

      &amp;lt;fieldset&amp;gt;
        &amp;lt;input placeholder="Your name" name="name" type="text" tabindex="1" autofocus&amp;gt;
      &amp;lt;/fieldset&amp;gt;
      &amp;lt;fieldset&amp;gt;
        &amp;lt;input placeholder="Your Email Address" name="email" type="email" tabindex="2"&amp;gt;
      &amp;lt;/fieldset&amp;gt;
      &amp;lt;fieldset&amp;gt;
        &amp;lt;textarea name="message" placeholder="Type your Message Details Here..." tabindex="5"&amp;gt; 
 &amp;lt;/textarea&amp;gt;
      &amp;lt;/fieldset&amp;gt;

       &amp;lt;!-- Multiple file attachment --&amp;gt;
      &amp;lt;fieldset&amp;gt;
        &amp;lt;label for="file"&amp;gt;
          &amp;lt;h3&amp;gt; Upload your documents:&amp;lt;/h3&amp;gt;
        &amp;lt;/label&amp;gt;
        &amp;lt;input name="file[]" multiple="multiple" type="file"&amp;gt;
      &amp;lt;/fieldset&amp;gt;

      &amp;lt;fieldset&amp;gt;
        &amp;lt;button type="submit" name="send" id="contact-submit"&amp;gt;Submit Now&amp;lt;/button&amp;gt;
      &amp;lt;/fieldset&amp;gt;
    &amp;lt;/form&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  PHPMailer Source Code
&lt;/h2&gt;

&lt;p&gt;Copy the below source code and change the data according to your preferences:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

//required files
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';

//Create an instance; passing `true` enables exceptions
if (isset($_POST["send"])) {

  $mail = new PHPMailer(true);

    //Server settings
    $mail-&amp;gt;isSMTP();                              //Send using SMTP
    $mail-&amp;gt;Host       = 'smtp.gmail.com';       //Set the SMTP server to send through
    $mail-&amp;gt;SMTPAuth   = true;             //Enable SMTP authentication
    $mail-&amp;gt;Username   = 'your email address';   //SMTP write your email
    $mail-&amp;gt;Password   = 'app password';      //SMTP password
    $mail-&amp;gt;SMTPSecure = 'ssl';            //Enable implicit SSL encryption
    $mail-&amp;gt;Port       = 465;                                    

    //Recipients
    $mail-&amp;gt;setFrom( $_POST["email"], $_POST["name"]); // Sender Email and name
    $mail-&amp;gt;addAddress('example@gmail.com');     //Add a recipient email  
    $mail-&amp;gt;addReplyTo($_POST["email"], $_POST["name"]); // reply to sender email

    //multiple file attachment
  for ($i = 0; $i &amp;lt; count($_FILES['file']['tmp_name']); $i++) {
     $mail-&amp;gt;addAttachment($_FILES['file']['tmp_name'][$i], $_FILES['file']['name'][$i] ); 
  }

    //Content
    $mail-&amp;gt;isHTML(true);               //Set email format to HTML
    $mail-&amp;gt;Subject = 'Received New Message From: '. $_POST["name"];   // email subject headings
    $mail-&amp;gt;Body    = $_POST["message"]; //email message

    // Success sent message alert
    $mail-&amp;gt;send();
    echo
    " 
    &amp;lt;script&amp;gt; 
     alert('Message was sent successfully!');
     document.location.href = 'index.php';
    &amp;lt;/script&amp;gt;
    ";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Incorporating multiple file attachments in PHPMailer emails for form submissions can greatly enhance your web application’s functionality and user experience. With the right setup and practices, you can streamline the process of collecting essential files from users and ensure smooth communication between your website and its visitors.&lt;/p&gt;

&lt;p&gt;Now that you’ve learned how to attach multiple files using PHPMailer, you can provide an improved user experience while efficiently collecting data.&lt;/p&gt;

&lt;p&gt;Now, let’s address some frequently asked questions (FAQs) related to PHP Mailer and email functionality.&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Send HTML Form via PHP Mailer</title>
      <dc:creator>HMA WebDesign</dc:creator>
      <pubDate>Sun, 17 Mar 2024 10:53:53 +0000</pubDate>
      <link>https://dev.to/hmawebdesign/how-to-send-html-form-via-php-mailer-4mf9</link>
      <guid>https://dev.to/hmawebdesign/how-to-send-html-form-via-php-mailer-4mf9</guid>
      <description>&lt;h2&gt;
  
  
  What is PHP Mailer?
&lt;/h2&gt;

&lt;p&gt;Before we dive into the details, let’s briefly introduce PHP Mailer. PHP Mailer is a robust PHP library that simplifies the process of sending emails through PHP scripts. It offers an intuitive and feature-rich interface for sending plain text and HTML emails, complete with attachments and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps – Send HTML Form via PHP Mailer
&lt;/h2&gt;

&lt;p&gt;Let’s start with a detailed outline that will guide us to Send HTML Form via PHP Mailer through this extensive guide. Here are the important steps to Send an HTML Form via PHP Mailer on HTML form submission:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download and install PHP Mailer from GitHub&lt;/li&gt;
&lt;li&gt;Setup your HTML Contact Form&lt;/li&gt;
&lt;li&gt;Include PHP Mailer in your HTML code&lt;/li&gt;
&lt;li&gt;Configure PHP Mailer&lt;/li&gt;
&lt;li&gt;Process form data to send email&lt;/li&gt;
&lt;li&gt;Compose the Email&lt;/li&gt;
&lt;li&gt;Handle Success and Error messages&lt;/li&gt;
&lt;li&gt;Send the Email&lt;/li&gt;
&lt;li&gt;Video Tutorial – Send HTML Form via PHP Mailer&lt;/li&gt;
&lt;li&gt;Now that we have our roadmap, let’s explore each section in detail to Send HTML Form via PHP Mailer.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How to Send HTML Form to Email Using PHP Mailer
&lt;/h2&gt;

&lt;p&gt;Sending HTML forms via email is a seamless process when you have PHP Mailer at your disposal. Here’s a step-by-step guide to achieving, how to send HTML form via PHP Mailer:&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before diving into implementation, ensure that you have the following prerequisites in place:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Web Server with PHP Support:&lt;/strong&gt; You’ll need a web server, such as Apache or Google, with PHP support to run your PHP Mailer script.&lt;br&gt;
Email Server Access: Ensure you have access to an email server or SMTP server to send emails, such as Gmail.&lt;br&gt;
Basic HTML and PHP Knowledge: Familiarize yourself with HTML to create the form and PHP to process it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step by Step Video Tutorial:
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/9Db7JtLht8I"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Let’s start by downloading PHP Mailer and setting up our HTML form to Send HTML Form via PHP Mailer:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Download and install PHP Mailer&lt;/strong&gt;&lt;br&gt;
Begin by downloading the PHP Mailer library. You can obtain it from the official GitHub repository or use Composer if you prefer package management.&lt;/p&gt;

&lt;p&gt;To Download the PHP Mailer manually from the GitHub library &lt;a href="https://github.com/PHPMailer/PHPMailer"&gt;Click Here&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;If you want to install the PHPMailer using Composer. First of all, simply install the &lt;a href="https://getcomposer.org/"&gt;Composer Setup&lt;/a&gt; on your computer and run the following command in your terminal:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;u&gt;&lt;strong&gt;composer require phpmailer/phpmailer&lt;/strong&gt;&lt;/u&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Alternatively, if you’re not using Composer, you can &lt;a href="https://github.com/PHPMailer/PHPMailer/archive/master.zip"&gt;download PHPMailer&lt;/a&gt; as a zip file, and then copy the contents of the PHPMailer folder into one of the include_path directories specified in your PHP configuration and load each class file manually:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Set Up Your HTML Form&lt;/strong&gt;&lt;br&gt;
Create an HTML form on your website where users can submit their information. Ensure that your form fields have appropriate name attributes.&lt;/p&gt;
&lt;h2&gt;
  
  
  HTML Form Source Code
&lt;/h2&gt;

&lt;p&gt;I have created a simple HTML form to send web form data to email using PHPMailer. I will collect this form data from the user and send it to my email address using PHPMailer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
  &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
  &amp;lt;style&amp;gt;
    @import url(https://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,600);

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-weight: 300;
      font-size: 12px;
      line-height: 30px;
      color: #272727;
      background: rgb(25, 199, 155);
    }

    .container {
      max-width: 400px;
      width: 100%;
      margin: 0 auto;
      position: relative;
    }

    #contact input {
      font: 400 12px/16px;
      width: 100%;
      border: 1px solid #CCC;
      background: #FFF;
      margin: 10 5px;
      padding: 10px;
    }

    h1 {
      margin-bottom: 30px;
      font-size: 30px;
    }

    #contact {
      background: #F9F9F9;
      padding: 25px;
      margin: 50px 0;
    }


    fieldset {
      border: medium none !important;
      margin: 0 0 10px;
      min-width: 100%;
      padding: 0;
      width: 100%;
    }

    textarea {
      height: 100px;
      max-width: 100%;
      resize: none;
      width: 100%;
    }

    button {
      cursor: pointer;
      width: 100%;
      border: none;
      background: rgb(17, 146, 60);
      color: #FFF;
      margin: 0 0 5px;
      padding: 10px;
      font-size: 20px;
    }

    button:hover {
      background-color: rgb(15, 95, 42);
    }
  &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
  &amp;lt;div class="container"&amp;gt;
    &amp;lt;form id="contact" action="mail.php" method="post"&amp;gt;
      &amp;lt;h1&amp;gt;Contact Form&amp;lt;/h1&amp;gt;

      &amp;lt;fieldset&amp;gt;
        &amp;lt;input placeholder="Your name" name="name" type="text" tabindex="1" autofocus&amp;gt;
      &amp;lt;/fieldset&amp;gt;
      &amp;lt;fieldset&amp;gt;
        &amp;lt;input placeholder="Your Email Address" name="email" type="email" tabindex="2"&amp;gt;
      &amp;lt;/fieldset&amp;gt;
      &amp;lt;fieldset&amp;gt;
        &amp;lt;input placeholder="Type your subject line" type="text" name="subject" tabindex="4"&amp;gt;
      &amp;lt;/fieldset&amp;gt;
      &amp;lt;fieldset&amp;gt;
        &amp;lt;textarea name="message" placeholder="Type your Message Details Here..." tabindex="5"&amp;gt;&amp;lt;/textarea&amp;gt;
      &amp;lt;/fieldset&amp;gt;

      &amp;lt;fieldset&amp;gt;
        &amp;lt;button type="submit" name="send" id="contact-submit"&amp;gt;Submit Now&amp;lt;/button&amp;gt;
      &amp;lt;/fieldset&amp;gt;
    &amp;lt;/form&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Include PHP Mailer&lt;/strong&gt;&lt;br&gt;
In your PHP script, include the PHP Mailer library using require or require_once. as shown in the following script:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Configure PHP Mailer&lt;/strong&gt;&lt;br&gt;
Set up PHP Mailer with your email server details, including the SMTP host, username, password, and port. Make sure to use valid credentials and a secure connection.&lt;/p&gt;

&lt;p&gt;If you are using a Gmail SMTP server, first of all, login to your Gmail ID, turn on 2-step authentication and, generate an App Password. To generate an App Password in your Gmail account &lt;strong&gt;&lt;a href="https://myaccount.google.com/apppasswords"&gt;follow this link&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Process Form Data&lt;/strong&gt;&lt;br&gt;
In your PHP script, retrieve the form data submitted by the user using $_POST or $_GET, depending on your form’s method attribute. In this tutorial, we have received the following form data from the user:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Compose the Email&lt;/strong&gt;&lt;br&gt;
Use PHP Mailer to compose your email. You can format it as plain text or HTML, depending on your preference. Here is the complete PHPMailer source code to send HTML form via PHP Mailer:&lt;/p&gt;
&lt;h2&gt;
  
  
  PHPMailer Source Code
&lt;/h2&gt;

&lt;p&gt;Copy the below source code and change the data according to your preferences:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

//required files
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';

//Create an instance; passing `true` enables exceptions
if (isset($_POST["send"])) {

  $mail = new PHPMailer(true);

    //Server settings
    $mail-&amp;gt;isSMTP();                              //Send using SMTP
    $mail-&amp;gt;Host       = 'smtp.gmail.com';       //Set the SMTP server to send through
    $mail-&amp;gt;SMTPAuth   = true;             //Enable SMTP authentication
    $mail-&amp;gt;Username   = 'your email address';   //SMTP write your email
    $mail-&amp;gt;Password   = 'app password';      //SMTP password
    $mail-&amp;gt;SMTPSecure = 'ssl';            //Enable implicit SSL encryption
    $mail-&amp;gt;Port       = 465;                                    

    //Recipients
    $mail-&amp;gt;setFrom( $_POST["email"], $_POST["name"]); // Sender Email and name
    $mail-&amp;gt;addAddress('example@gmail.com');     //Add a recipient email  
    $mail-&amp;gt;addReplyTo($_POST["email"], $_POST["name"]); // reply to sender email

    //Content
    $mail-&amp;gt;isHTML(true);               //Set email format to HTML
    $mail-&amp;gt;Subject = $_POST["subject"];   // email subject headings
    $mail-&amp;gt;Body    = $_POST["message"]; //email message

    // Success sent message alert
    $mail-&amp;gt;send();
    echo
    " 
    &amp;lt;script&amp;gt; 
     alert('Message was sent successfully!');
     document.location.href = 'index.php';
    &amp;lt;/script&amp;gt;
    ";
}
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Handle Success and Error messages&lt;/strong&gt;&lt;br&gt;
Implement error handling to deal with scenarios where the email-sending process might fail. Display a success message to the user upon successful submission.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Send the Email&lt;/strong&gt;&lt;br&gt;
Use the send method to send the email. Ensure to implement error handling to deal with scenarios where the email-sending process might fail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Testing Your Setup&lt;/strong&gt;&lt;br&gt;
After implementing the above steps, thoroughly test your setup. Submit test data through your HTML form to ensure that emails are being sent correctly to the specified email address.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In conclusion, PHP Mailer is a powerful tool that simplifies the process of sending HTML forms to email addresses. By following the steps outlined in this guide, you can enhance user interaction on your website and efficiently collect user information, feedback, and inquiries. Remember to handle errors gracefully and ensure the security of user data during transmission.&lt;/p&gt;

&lt;p&gt;Now, let’s address some frequently asked questions (FAQs) related to PHP Mailer and email functionality.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>php</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to Create a Website Without Coding Knowledge</title>
      <dc:creator>HMA WebDesign</dc:creator>
      <pubDate>Tue, 10 Oct 2023 07:38:00 +0000</pubDate>
      <link>https://dev.to/hmawebdesign/how-to-create-a-website-without-coding-knowledge-3d8n</link>
      <guid>https://dev.to/hmawebdesign/how-to-create-a-website-without-coding-knowledge-3d8n</guid>
      <description>&lt;p&gt;If you want to learn How to Create a Website Without Coding Knowledge and you don’t know how to code, &lt;a href="https://hmablogs.com/create-a-website-without-coding-knowledge/"&gt;this article&lt;/a&gt; is for you. In today’s digital age, having an online presence is crucial for individuals and businesses alike. However, the idea of creating a website can be daunting, especially if you have no coding experience.&lt;/p&gt;

&lt;p&gt;The good news is that you don’t need to be a tech wizard to build a website. In this article, we will guide you through the process of how to create a website without coding knowledge. Whether you want a personal blog or a business website, we’ve got you covered.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents – Create a Website Without Coding
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
Here is the list of 13 practical steps to Create a Website Without Coding Knowledge:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Understanding the Basics&lt;/li&gt;
&lt;li&gt;Choosing the Right Website Builder.&lt;/li&gt;
&lt;li&gt;Setting Up Your Account&lt;/li&gt;
&lt;li&gt;Designing Your Website&lt;/li&gt;
&lt;li&gt;Adding Content&lt;/li&gt;
&lt;li&gt;Optimizing for SEO&lt;/li&gt;
&lt;li&gt;Launching Your Website&lt;/li&gt;
&lt;li&gt;Maintaining and Updating&lt;/li&gt;
&lt;li&gt;Troubleshooting Common Issues&lt;/li&gt;
&lt;li&gt;Promoting Your Website&lt;/li&gt;
&lt;li&gt;Measuring Success&lt;/li&gt;
&lt;li&gt;Protecting Your Website&lt;/li&gt;
&lt;li&gt;Expanding Your Website&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You Read the complete Article here:&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://hmablogs.com/create-a-website-without-coding-knowledge/" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--8eazMpAm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://hmablogs.com/wp-content/uploads/2023/09/Create-a-Website-Without-Coding-Knowledge.jpg" height="450" class="m-0" width="800"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://hmablogs.com/create-a-website-without-coding-knowledge/" rel="noopener noreferrer" class="c-link"&gt;
          How to Create a Website Without Coding Knowledge
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          We will guide you how to create a website without coding knowledge. Whether you want a personal blog or a business website, we've got you covered...
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://res.cloudinary.com/practicaldev/image/fetch/s--n2KbR_Gr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://hmablogs.com/wp-content/uploads/2023/08/cropped-HMA-Webdesign-32x32.jpg" width="32" height="32"&gt;
        hmablogs.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>wordpress</category>
    </item>
  </channel>
</rss>
