PHP Job Application Form

Last Updated on February 23, 2024 by Roshan Parihar

In this post, learn about the PHP job application form and the script for validation and send emails with form data. You will also get PHP code to insert applicants’ data into the database and display it in a table.

If you are running an online business, a job application form can be the best solution for you to collect applicants’ data from your website. You can add job application forms to your website career page.

PHP Job Application Form

Bonus Tip

Looking to create job application forms without coding? Create beautiful-looking job application forms with JotForm.

Each time when your applicants want to apply for your job, they will visit to career page and fill out the job application form to apply for your job. After collecting applicants’ data, you can start further communication with them to hire for your company.

You can easily create a job application form and collect data via emails using PHP. The job application form sends emails only after getting valid entries from users. It also inserts data into the database after getting the valid data from applicants.

So, let’s get started.

PHP Job Application Form Appearance

The job application form should contain all the necessary fields to collect applicants’ data good enough to apply. It also contains an email, phone number, job position, experience, and resume in PDF.

Longer size job application forms make it difficult for applicants to fill in data. That way, to make the job application form as simple as possible I have decided to add only the below given form fields:-

  • Name
  • Email Address, and
  • Phone number
  • Position applying for
  • How Many Years of Experience?
  • Cover Letter, and
  • Resume Upload

The above fields are enough to collect applications with applicants’ useful data easily. The HTML code for the job application form is given below.

The appearance of the form is shown in the image below. The interface does not look good enough to make it beautiful. You have to add some CSS for styling and make a better user experience.

Job Application Form in HTML

To add styling to your job application form, you have to add some CSS given below. It styles all the input fields, select field, textarea, and the submit button of the form. You can change the submit button color to match your website brand color.

Add Style to Job Application Form

After adding styling to your job application form, your form appearance changed like the image shown below. Now, the interface looks better than before and is good to add to your website and display to your users. It is also responsive to easily display according to any screen size like desktop, laptop, tablet, and mobile.

Job Application Form Format

Now, let’s add some validation to your job application form to collect valid data from applicants. After that, you can collect valid applicant data via email with the PHP code given below.

PHP Job Application Form Add Validation and Send Data Via Emails

To make your field required to fill for applicants, you can add required attribute to your fields. The main validation here which is required is for email format, Phone number, and file type.

Validate Phone Number Using Javascript

Set the phone number input field type as input type="tel".To get the phone number in numeric format, you can add the below validation function and add an attribute oninput="validationall('tel', '0-9')" to your phone number field.

Also, if you want to allow applicants to enter only 10-digit numbers as phone numbers, you have to add an attribute maxlength = "10". So, your input field for the phone will change to the field given below.

Validate Email Address and Resume Uploaded PDF File Using PHP

The below example code matches the email regex expression with the user input email address to find the valid email address. If the email address is not valid, it displays error messages.

When the user enters a valid email address, it executes the next PHP code that checks the file for validation. The file validation checks the file size and file type to be PDF and of specified size.

Please see the email address and file validation below using PHP to get an idea.

Send Form Data Via Email

To collect applicants’ entered data via email to your email address, we are going to use SMTP. For this, you have to first download the PHPMailer library with the button given below.

Download PHPMailer

After that, use the below code just after the above PHP code. If every form entered data of the applicant is correct and valid, it executes the below code to send the form data via email.

Note: don’t forget to change the $sender value with your Gmail address, $gmailapppassword value with the Gmail app password, and the recipient email address with your email and name.

Now, next is to insert the applicant’s data into the MySQL database and display it on a page. Let’s do this in the next section.

Insert Form Data Into Database and Display in a Page

In this section, you will learn to insert the form data into the database. This is useful to store and find them again to easily call them when required. After you insert the data, you can display the data anywhere on your website posts and pages.

Firstly, you have to open PHPMyadmin of your MySQL database.

login to PHPMyAdmin

phpmyadmin-login PHP

After that, open the ‘SQL’ tab there.

Open the ‘SQL’ tab of PHPMyAdmin

phpmyadmin-dasboard-click-sql-tab

Create a database to insert PHP Job Application form data

Now, copy the below SQL code and add it to the input area given in the ‘SQL’ tab. After that, press the ‘Go’ button to execute the below SQL code and create a database with the name ‘create_forms’.

phpmyadmin-add-code-click-go-to-insert-db

The below SQL code also creates a table ‘job_application_form’ with the creation of the database ‘create_forms’. This is the table where you have to store your applicant’s data entered in the job application form.

Now, you are ready with your database and a table with all the fields to insert the form data.

Connect to Your Database Using PHP

After you create the database, you have to connect to the database using the PHP code given below. The code requires the server name, the username of the database, the password of the database user, and the database name.

The code also displays a success message after a successful connection is made with the database.

Insert Job Application Form Data Into the Database

Now, to insert the job application form data into your above-created database, you have to use the PHP code given below. The code for the PHP job application form inserts the data into the database using the SQL insert query.

Now, you have successfully sent the email and inserted the form data into the database. It’s time to display the applicants entered data on your website page. This makes it easier for the website owner to keep a record of the applicants.

Display Inserted Data in a Table

To display the data in a table, you have to first select the table ‘job_application_form’ and check whether it contains applicants’ records or not. When it contains some data, it displays all the data in a table using a while loop in PHP.

You will get the applicant’s data in the table format on your website as shown in the image below. To make your table look better on your website, you also have to add some style as given below.

phpmyadmin-add-code-click-go-to-insert-db PHP Job Application Form

You May Also Like to Read

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.