Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Contact Form ! Help me....

Featured Replies

Hello everyone , 

i have a problem with my contact Form ....

Ι fill in the fields of the contact form and click send.

The mail goes normally but blank. Without any of the data I put in the fields.

Look my Code.

sendemail.php File

<?php
$name       = $_POST['name']; 
$from       = $_POST['email']; 
$subject    = $_POST['subject']; 
$message    = $_POST['message']; 
$to           = 'info@geapellas.gr';//replace with your email

$headers   = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: {$name} <{$from}>";

mail($to, $subject, $message, $headers);

die;

 

Html Contact index File

                         <form id="main-contact-form" name="contact-form" method="post" action="sendemail.php">
                               <div class="form-group">
                                <input type="text" placeholder="Όνομα" class="form-control" name="name" id="name">
                            </div>
                            
                            <div class="form-group">
                                <input type="email" placeholder="Email" class="form-control" name="email" id="email">
                            </div>
                            
                            <div class="form-group">
                                <input type="text" placeholder="Θέμα" class="form-control" name="subject" id="subject">
                            </div>
                            
                            <div class="form-group">
                                <textarea rows="6" placeholder="Μήνυμα" class="form-control" name="message" id="message"></textarea>    
                            </div>
                                <button type="submit" id="contact-submit" class="btn btn-primary">Αποστολή</button>
                            </form>

Can someone find the problem please ?

 

Thanks 

It’s probably being block by your host. Many don’t allow post data in the from name/email fields.

You also need to validate the data. Right now you have left an open door for anyone to hack your site.

  • 2 years later...

Hi, I have tried and checked your code in sendemail.php I think there is some problem in $headers[], try this code, it works fine.

<?php
$name       = $_POST['name']; 
$from       = $_POST['email']; 
$subject    = $_POST['subject']; 
$message    = $_POST['message']; 
$to           = 'info@geapellas.gr';//replace with your email

$headers = "From: $from";

mail($to, $subject, $message, $headers);

die;
?>

 

  • 2 months later...

The issue occurs because you are passing an array of headers into the mail() function, while the mail() function expects a string for the headers. You need to convert the headers array into a string before passing it to the function.

Here’s how to fix it:

<?php
// Retrieve form data
$name       = $_POST['name']; 
$from       = $_POST['email']; 
$subject    = $_POST['subject']; 
$message    = $_POST['message']; 
$to         = 'info@geapellas.gr'; // Replace with your email

// Build headers
$headers   = "MIME-Version: 1.0" . "\r\n";
$headers  .= "Content-type: text/plain; charset=iso-8859-1" . "\r\n";
$headers  .= "From: {$name} <{$from}>" . "\r\n";

// Send email
mail($to, $subject, $message, $headers);

// Optional: Redirect or show success message
echo "Email sent successfully!";
die;
?>

Key Changes:

1. Headers as a String: Instead of using an array for $headers, I concatenated the headers into a string, which is required by the mail() function.

2. Newline Characters (\r\n): Each header line is separated using \r\n, which is the standard for email headers.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.