Contact me form error

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Thu Mar 28, 2013 6:15 am

Contact me form error

Postby waidinho » Thu Mar 28, 2013 6:22 am

I have following form:

Code: Select all

<form id="form" class="blocks" action="email.php" method="post">
         <label>Name: <font style="color:red">*</font></label>
         <input type="text" class="text" name="name"/>
         <label>e-mail <font style="color:red">*</font></label>
         <input type="text" class="text" name="email"/>
         <label>Phone: </label>
         <input type="text" class="text" name="phone"/>
         <label>Subject: <font style="color:red">*</font></label>
         <input type="text" class="text" name="theme" />
      <p class="area">
         <label>Message: <font style="color:red">*</font></label>
         <textarea class="textarea" name="message"></textarea>
         <input type="submit" class="btn" value="Siųsti laišką" />

When i fill in form and send email to my gmail acc, in my gmail it shows me that email sender is "unknown". How to make it show correctly $name? My php code is below:

Code: Select all

$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
$message = $_POST['message'];

$email_subject = "$subject";
$email_body = "         name: $name.\n
            e-mail: $email.\n
            phone: $phone.\n
            subject: $subject.\n
            message: $message.\n";
$to = "";
$headers = "From: $name \r\n";
$headers .= "Reply-To: $email \r\n";

header('Location: email-sent.php');   

User avatar
php-forum GURU
php-forum GURU
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Contact me form error

Postby egami » Fri Mar 29, 2013 8:08 am

make sure that $_POST['name'] is actually defined and is a valid email format.

Return to “Your Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests