1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Share Coding php contact form

Discussion in 'PHP' started by inrev, Mar 14, 2011.

  1. #1
    Contact form with php:
    save with contact.html

    
    <form action="sent.php" method="post"> 
    <table width="400" border="0" cellspacing="2" cellpadding="0"> 
    <tr> 
    <td width="29%" class="bodytext">Your Name:</td> 
    <td width="71%"><input name="name" type="text" id="name" size="32"></td> 
    </tr> 
    <tr> 
    <td class="bodytext"> Email:</td> 
    <td><input name="email" type="text" id="email" size="32"></td> 
    </tr> 
    <tr> 
    <td class="bodytext">Comment:</td> 
    <td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td> 
    </tr> 
    <tr> 
    <td class="bodytext">&nbsp;</td> 
    <td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td> 
    </tr> 
    </table> 
    </form>  
    
    
    PHP:
    save with sent.php

    
    <?php 
    $ToEmail = 'email@site.com'; 
    $EmailSubject = 'Feedback/contact form '; 
    $mailheader = "From: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    $MESSAGE_BODY = "Visitor Name: ".$_POST["name"]."<br>"; 
    $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; 
    $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>"; 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
    ?> 
    
    PHP:

     
    Last edited: Mar 14, 2011
    inrev, Mar 14, 2011 IP
  2. Minimal Hank

    Minimal Hank Peon

    Messages:
    136
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    No input ( data ) validation ? Good bless your mailbox :D
     
    Minimal Hank, Mar 15, 2011 IP
  3. inrev

    inrev Peon

    Messages:
    60
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    validation you could made with javascript or add on new script.
    I just share basic contact form, mate :)
     
    inrev, Mar 18, 2011 IP
  4. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    srisen2, Mar 18, 2011 IP
  5. Minimal Hank

    Minimal Hank Peon

    Messages:
    136
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If one will find this useful, he won't have any idea on how to add validation or anything of that kind. And again, in my opinion, useless ..
     
    Minimal Hank, Mar 18, 2011 IP
    sarahk likes this.