treehouse : what would you like to learn today?
Web Design Web Development iOS Development

need code for this EMAIL FORM

  • Hi!
    I need a php code for my email form I've found some but I don't know how to include it. Can you guys help me!! Please! Thank you!

    <form action="form_action.asp" method="get">

    <p class="n">Nombre:</p><input type="text" name="f_nombre" class="f_1" /><br />

    <p class="e">E-mail:</p><input type="text" name="f_email" class="f_1" /><br />

    <p class="m">Mesaje:</p><textarea name="mensaje" rows="15"></textarea><br />

    <input class="boton" type="submit" value="Submit" />

    </form>


    here's the website http://www.cetem.com.mx/tecnico.html
  • Hi,

    Not wishing to sound rude but I think you may be out of your depth here.

    A couple of things
    1, The form action needs to point to the PHP page that you want to send the email. At the moment it's pointing to an ASP page.
    2, The form method should be post really.

    To give you some idea the input name fields will become the variable names in your PHP.
    So in PHP the first name variable will be
    $_POST['f_nombr']


    Now you have your variables you just need to attach them to the email


    $to = "you@yours.com";
    $subject = "Contact Form";
    $body = "First name: " . $_POST['f_nombr'];
    mail($to, $subject, $body);
  • thanks man!
  • Replace your "p" tags with "label" tags aswell.

    Also suggest when collecting the form data with PHP run it though htmlentities()for security.

    $f_nombr = htmlentities($_POST['f_nombre']);
  • Thank you
    Do you have any html email form tutorial that you can refer me to?