My contact form sends blank body_messages

前端 未结 1 1458
时光取名叫无心
时光取名叫无心 2021-01-13 00:40

I’m new to PHP so bear with me. My form is sending empty emails when I press submit. Any help would be great.

This is my form:

    
相关标签:
1条回答
  • 2021-01-13 01:04

    Try this

     <form class="contact_form" action="kontakt.php" method="post">
        <p><input type="text" required="required" id="name" name="name" class="text_input" size="22"  />
        <label for="name">Namn *</label></p>
    
        <p><input type="text" required="required" id="company" name="company" class="text_input" size="22"  />
        <label for="company">Företag *</label></p>
    
        <p><input type="email" required="required" id="email" name="email" class="text_input"  size="22"  />
        <label for="email">Epost *</label></p>
    
        <p><textarea required="required" name="content" class="textarea" cols="30" rows="5"></textarea></p>
    
        <p><button type="submit" class="button white"><span>Skicka</span></button></p>
        <input type="hidden" value="info@web.se" name="contact_to"/>
    </form>
    

    Edit:(Debug)

    $name = $_POST['name'];
    $company = $_POST['company'];
    $email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
    $content = $_POST['content'];
    
    echo $name.$comapny.$email.$content;exit; // check whether the values are posted successfully or not
    
    0 讨论(0)
提交回复
热议问题