Actually I was creating a simple form to send mail to my email ID. Here's my code:
<!doctype html>
<html>
    <body>
        <form>
            <input type='text' name='name'>
            <input type='email' name="email">
            <input type="number" name="mobile">
            <input type="text" name="message">
            <input type="submit" name='submit'>
        </form> 
    </body>
</html>
php code:
<?php
if($_POST['submit']!="")
{
 $cname = $_POST['name'];
 $email = $_POST['email'];
 $mob = $_POST['mobile'];
 $query = $_POST['message'];
 $subject="Enquiry";
 $message="Name : $cname \n  email : $email \n  Message : $query \n";
 $email_from = '<name@gmail.com.com>';
 $subject = "registration";
 $message = "You have received a new message from the user <b> $cname. </b> \n". "Here is the message:\n $message".
 $to = "name<name@gmail.com>";
 $headers = "From: $email_from \r\n";
 $headers.= "Reply-To: $email \r\n";
    if(mail($to, $subject, $message, $headers))
    {
     echo "<script>alert('Dear User, You Are Successfully Registered')</script>";
    }
}
?>
Note: In this question I have changed my actual email id with "name", in my actual code, the id is putten correctly. The error is in the first if statement that the 'submit' is undefined.
 
    