Adblock breaks this site

need some instruction on form

Discussion in 'Web Programming' started by DaveHester, Nov 23, 2016.

  1. DaveHester

    DaveHester Apprentice

    Joined:
    Sep 4, 2014
    Posts:
    642
    Referrals:
    2
    Sythe Gold:
    363
    need some instruction on form

    made a website for a family member but im pretty basic when it comes to html but no clue how exactly this form is suppose to work. basically im trying to make a form send the info to a email address but not sure how exactly how to set it up and make it actually work if someone could help me with this would be greatly appreciated.


    Code:
    <form action=" http://mailto:[email protected]" method="post" enctype="text/plain">
    
      Name:<br>
    <input type="text" name="name"><br>
    E-mail:<br>
    <input type="text" name="mail"><br>
    Phone:<br>
    <input type="text" name="phone"><br>
    Comment:<br>
    <input type="text" name="comment" size="50"><br><br>
    <input type="submit" value="Send">
    <input type="reset" value="Reset">
    </form>
     
  2. kmjt

    kmjt -.- The nocturnal life chose me -.-
    Banned

    Joined:
    Aug 21, 2009
    Posts:
    14,450
    Referrals:
    8
    Sythe Gold:
    449
    need some instruction on form

    Form validation (at least on phone number)
     
  3. 70i

    70i Forum Addict
    Banned

    Joined:
    Jan 11, 2014
    Posts:
    462
    Referrals:
    0
    Sythe Gold:
    174
    need some instruction on form

  4. murinsh

    murinsh Member
    Banned

    Joined:
    Jul 25, 2016
    Posts:
    40
    Referrals:
    0
    Sythe Gold:
    47
    need some instruction on form

    I don't get why W3Schools is piece of garbage, it gives really nice fundementals to get started.

    As for the question, you can't send email with just html form, you need to look in to php and SMTP (Simple Mail Transfer Protocol)
     
  5. 70i

    70i Forum Addict
    Banned

    Joined:
    Jan 11, 2014
    Posts:
    462
    Referrals:
    0
    Sythe Gold:
    174
    need some instruction on form

    The code on that site usually works, but just for one case. If you have practical requirements w3schools is not going to be enough.

    For instance let's say you want a checkbox for your website. You could go to HTML input checked Attribute

    But then you realize you want the users to be able to click the label beneath the checkbox to register as checking the box. You can look anywhere on their site and it won't tell you how to do this, not even in their "reference". Nor do they provide links to html's specification that specifies all of html's available features.

    On the other hand, if you had the same requirement and went to MDN <input type="checkbox">. It shows you how to do that in the example. If you needed something else that's not covered in the example at least it gives you a reference to HTML's specification where you can see all of HTML's features HTML Standard

    HTML is the simplest language W3Schools covers, and learning this way is much worse with the more complicated languages W3Schools tries to teach.

    TLDR W3Schools isn't scalable. They'll give you a fish, but won't teach you to fish.
     
  6. Viral_

    Viral_ Grand Master

    Joined:
    Jul 21, 2017
    Posts:
    2,483
    Referrals:
    1
    Sythe Gold:
    3,211
    Discord Unique ID:
    827322595988865025
    need some instruction on form

    Revised Code:

    HTML:
    <form action="send.php" method="post" enctype="text/plain">
      <div class="form-group">
        <label>Email:</label>
        <input type="text" name="email" class="form-control">
      </div>
      <div class="form-group">
        <label>Phone:</label>
        <input type="text" name="phone" class="form-control">
      </div>
      <div class="form-group">
        <label>Comment:</label>
        <textarea rows="5" class="form-control" name="comment"></texarea>
      </div>
      <div class="form-group">
        <input type="submit" name="send" class="btn btn-primary">
      </div>
    </form>
    send.php

    PHP:
    <?PHP

      
    if(isset($_POST['send']) && !empty($_POST['send'])) {
        
    $email $_POST['email'];
        
    $phone $_POST['phone'];
        
    $comment $_POST['comment'];

        
    $htmlEmail '';
        
    $htmlEmail .= '<p><span style="font-weight:600">Phone:</span> '.$phone.'</p>';
        
    $htmlEmail .= '<p><span style="font-weight:600">Comment:</span> '.$comment.'</p>';
        
    mail($email'Test Email'$htmlEmail);
      }
    ?>
     
< | >


 
 
Adblock breaks this site