-2

So, i have this code, and cannot send an inputs to my email, how can I solve this problem? I have tried millions of methods but still I cannot solve this issue, I watched lots of videos and tutorials but I think the problem is in my code. How can I make this code work?

 <form action="email_handler.php">
    <div class="subscribe-form">
        <h2 class="heading">Check your compatibility with your favorite person </h2>
        <div class="grid grid--gutter-small grid--auto-sizing">

            <div class="grid  grid__item">
                <label for="firstName">Your name</label>
                <input action="mailto:nersisyan21@mail.ru" id="mynum" placeholder="Name" class="input" type="text"  name="name1" required />
            </div>

            <div class="grid  grid__item">
                <label for="lastName">Your surname</label>
                <input id="mynum1" placeholder="Surname" class="input" type="text" name="name2" required/>
            </div>

            <div class="grid  grid__item">
                <label for="lastName">His/Her name</label>
                <input id="mynum2" placeholder="Name" class="input" type="text" name="name3" required />
            </div>

            <div class="grid  grid__item">
                <label for="lastName">His/Her surname</label>
                <input id="mynum3" placeholder="Surname" class="input" type="text" name="name4" required />
            </div>




            <div class="grid grid__item">
                <button type="button" id="check" class="button" name="submit">Check</button>
            </div>

            <div class="grid grid__item">
                    <div class="out">
                        <p class="name2" id="out"></p>
                    </div>
                    </div>
        </div>
    </div>
    </form>
<?php  
    if(isset($_POST['submit'])){
        $name=$_POST['name'];
        $name1=$_POST['name1'];
        $name2=$_POST['name2'];
        $name3=$_POST['name3'];


        $to='example@example.com';
        $subject='Sovmestimost';
        $message="Name: ".$name."\n"."Surname: ".$name1."\n"."His/her name:      ".$name2."\n"."His/her second name: ".$name3;
        $headers="From: ".$name;
    }
?>
4
  • 1
    Have you tried actually sending the mail? Because the code for that is not in your question. Mar 5, 2018 at 13:24
  • 3
    The default send method for a form is GET, not POST. You've not specified the POST method in the form tag, so it will use GET. Mar 5, 2018 at 13:27
  • 1
    <input action="mailto:nersisyan21@mail.ru" - only <form> uses an action. Mar 5, 2018 at 13:28
  • 1
    name="name4" required - so you're not using that after, it'll just stop there. Mar 5, 2018 at 13:30

1 Answer 1

4

In you form method attribute is missing

<form action="email_handler.php" method ="post">
4
  • @JohnConde In Php file he using the post method
    – Siva
    Mar 5, 2018 at 13:27
  • I tried but it did not work Mar 5, 2018 at 13:29
  • @TaronNersisyan You've not got any code in the OP that would trigger a mail send.. Just something that constructs the headers Mar 5, 2018 at 13:32
  • So, how can i do that, pls help Mar 5, 2018 at 13:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.