How Do Freelance Designers Add a PHP Contact Form?
For Freelance web designers · Based on Traversy PHP Contact Form Build
// TL;DR
Freelance web designers can add a working contact form to any portfolio site using PHP's native mail() function—no third-party service, no monthly fee. Build an HTML form with name, email, budget, and message fields, process submissions in a separate contact_form.php file, and deliver inquiries to your hosted email. If you use Gmail as your primary inbox, set up domain-level forwarding to relay messages automatically. This method works on any shared hosting plan and takes under 30 minutes to implement.
Why should freelance designers use a PHP contact form on their portfolio site?
A contact form is the most important conversion element on a freelance portfolio site. It removes the friction of visitors having to open their email client, copy your address, and compose a message. PHP's native mail() function lets you handle this entirely on your own hosting—no Formspree submissions limits, no EmailJS API keys, no monthly charges from third-party services.
The Traversy PHP Contact Form Build gives you a clean, repeatable method: your HTML form lives in index.php, the processing logic lives in contact_form.php, and the two are connected by the form's action attribute. This separation means you can redesign the form's appearance without touching the email logic.
How do you set up the form for client inquiries?
Start with four fields that cover what you need from every potential client:
- Name — ``
- Email — ``
- Project type or budget — ``
- Message — ``
Add a submit button with `name="submit"` — this exact name attribute is critical because the PHP processor checks for it with `isset($_POST['submit'])`. If the names don't match, no email will ever send.
Set the form tag to `
// FREQUENTLY ASKED QUESTIONS
Can I reuse this PHP contact form across multiple client projects?
Yes, the structure is fully reusable. Copy index.php and contact_form.php to each project, change the $mail_to variable to the client's hosted email address, and adjust the form fields and $txt greeting to match the project. The isset() gate, redirect pattern, and header construction stay identical every time.
Do I need a specific hosting provider for this to work?
Any shared hosting plan that supports PHP and has a configured mail transfer agent will work. Providers like SiteGround, Bluehost, HostGator, and A2 Hosting all support PHP mail() out of the box. Static hosts like Netlify or Vercel do not run PHP and cannot be used.
How do I add spam protection to a portfolio contact form?
Add Google reCAPTCHA to the HTML form and verify the token server-side in contact_form.php before calling mail(). Alternatively, add a honeypot field—a hidden input that bots fill out but humans don't. If the honeypot field contains data, skip the mail() call. Both methods work within the existing PHP processor structure.