 <p>Your code contains several mistakes. I just removed all those. </p> <p>Try this:</p> <p>->Input field has no name field. i set it in form. you can also pass this as string inside your code. </p> <p>->You are not set $subject field yet ,but you are trying to access values from this and this will make error in mail sending fiel (inside mail()). </p> <p>->Don't need to check post values for each values just set what i did with form submit type name.</p> <p>-> pls try to use form tags to process input form fields</p> <pre><code>&lt;?php $errors = array(); if (isset($_POST['submit'])) { $name = htmlentities(mysql_real_escape_string($_POST['name'])); $email = htmlentities(mysql_real_escape_string($_POST['email'])); $ip = $_SERVER['REMOTE_ADDR']; if (empty($name) || empty($email)) { $errors[] = '&lt;div id="error"&gt;All fields are required.&lt;/div&gt;'; } if ( strlen($email)&gt;1024) { $errors[] = '&lt;div id="error"&gt;One or more fields exceeded the character limit.&lt;/div&gt;&lt;br /&gt;'; } if (empty($errors)) { function email($to, $subject, $body) { mail($to, $subject, $body, 'support@astrominds.in'); } email("abc@xyz.com","Contact Message", "Your Subject: Type subject\n" , "Ip: $ip\n"."Your Name: $name\n"."Your Email: $email\n"); echo "Form Works Success"; } } ?&gt; &lt;form method="post" action="formnot.php"&gt; &lt;label class="label"&gt;Email&lt;/label&gt; &lt;input type="text" id="f1" class="detail" name="email" autocapitalize="words" autocorrect="off" /&gt; &lt;label class="label"&gt;Name&lt;/label&gt; &lt;input type="text" name="name" /&gt; &lt;input type="submit" value="Continue" class="csssubmit" name="submit" &gt; &lt;/form&gt; </code></pre>