How to create a contact form in php

Discussion in 'Programming' started by taran_xi, Aug 4, 2014.

  1. #1
    Hey i m trying to make a website and little bit confuse to make a contact form
    Is there is anyone who can guide me


    Thank you
     
    taran_xi, Aug 4, 2014 IP
    happy_s and peter84 like this.
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    There are literally thousands of hits on "contact form php" on Google. And, seriously, if you're that green, I'd advice on maybe installing WordPress if you need the site up and running quickly, or sit down with basic PHP tutorials if you're just starting.
     
    PoPSiCLe, Aug 4, 2014 IP
  3. jetbrains

    jetbrains Well-Known Member

    Messages:
    1,747
    Likes Received:
    137
    Best Answers:
    0
    Trophy Points:
    133
    #3
    It's very easy to do it. The following is a very simple example without any Input Validations

    <html>
    <body>
    
    <form action="myform.php" method="post">
    <p>Your Name: <input type="text" name="yourname" /><br />
    E-mail: <input type="text" name="email" /></p>
    
    <p>Do you like this website?
    <input type="radio" name="likeit" value="Yes" checked="checked" /> Yes
    <input type="radio" name="likeit" value="No" /> No
    <input type="radio" name="likeit" value="Not sure" /> Not sure</p>
    
    <p>Your comments:<br />
    <textarea name="comments" rows="10" cols="40"></textarea></p>
    
    <p><input type="submit" value="Send it!"></p>
    </form>
    
    </body>
    </html>
    HTML:
    <html>
    <body>
    
    Your name is: <?php echo $_POST['yourname']; ?><br />
    Your e-mail: <?php echo $_POST['email']; ?><br />
    <br />
    
    Do you like this website? <?php echo $_POST['likeit']; ?><br />
    <br />
    
    Comments:<br />
    <?php echo $_POST['comments']; ?>
    
    </body>
    </html>
    PHP:
     
    jetbrains, Aug 12, 2014 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    And that's why the Web keeps going to the dogs. Fucked up markup, and no real usefulness, no doctype... I get that it's a basic example, but... Provide basic coding, at least?
     
    PoPSiCLe, Aug 13, 2014 IP
  5. taran_xi

    taran_xi Member

    Messages:
    54
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    45
    #5
    Thanx a lot for your help guys
     
    taran_xi, Aug 17, 2014 IP
  6. abhicyco

    abhicyco Active Member

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #6
    You could have simply searched on google and might have got thousands of contact us form in php...
     
    abhicyco, Aug 21, 2014 IP
  7. Krellen

    Krellen Greenhorn

    Messages:
    38
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    18
    #7
    While the example didn't actually do anything (like email the form), it does show you basically how to post a form to a PHP script. You probably want to do as everyone in here is suggesting and look at some PHP tutorials or just install a content management system like WordPress.
     
    Krellen, Sep 21, 2014 IP