Jump to content

CONTACT FORM


khujo56

Recommended Posts

  • Replies 53
  • Created
  • Last Reply

something different.......Here is a simple php contact form code that I am using on my website right now. Our website has the exact same form as yours on your website. (2 textfields and 1 text area) Just make sure you name your fields on the contact form the same as the fields in the body section of the php code.  This will email blank spaces as well as text.

<?php
$to = "[email protected]";
$subject = "Contact form";
$body = "
\n\n Name: $Name
\n\n E-Mail Address: $Email
\n\n Comments: $Comments";

mail ($to, $subject, $body);
header("Location: http://www.iheartvacation.com/");
?> 

Link to comment
https://forums.phpfreaks.com/topic/57653-contact-form/page/3/#findComment-290656
Share on other sites

  • 2 weeks later...

ok here is the html for the form

 

<form action="mailer.php" method="post" name="Form1" id="Form1" >

<div class="m" style="margin-left:8px; margin-bottom:4px ">Name</div>

<input name="name" type="text" id="name" style="width:290px; height:19px; font-family:Tahoma, Arial, Helvetica, sans-serif; font-size:10px; color:#848484 " onFocus="this.value=''" onClick="this.value=''" value="">

<img src="images/spacer.gif" height="4" style="display:block ">

<div class="m" style="margin-left:8px; margin-bottom:4px ">E-mail</div>

 

<input name="email" type="text" id="email" style="width:290px; height:19px; font-family:Tahoma, Arial, Helvetica, sans-serif; font-size:10px; color:#848484 " onFocus="this.value=''" onClick="this.value=''" value="">

<img src="images/spacer.gif" height="4" style="display:block ">

<div class="m" style="margin-left:8px; margin-bottom:4px ">Message</div>

 

<textarea name="message" id="message" style="width:445px; height:80px; overflow:hidden; font-family:Tahoma, Arial, Helvetica, sans-serif; font-size:10px; color:#848484 " onFocus="this.value=''"  onClick="this.value=''"></textarea>

<div style="padding-top:8px; margin-right:30px; margin-top:15px " align="right" class="red "><img src="images/kv.jpg" align="absmiddle" style="margin-right:5px ">

<a href="#" class="red2 " onclick="javascript:document.Form1.reset();">Reset</a>       <img src="images/kv.jpg" align="absmiddle" style="margin-right:5px ">

<input type="submit" name="submit" value="Submit">

</div>

</form

 

here is the code for the php:

 

<?php

if(isset($_POST['name']) && empty($_POST['name']))

{

    $error[] = "Post your name";

}

if(isset($_POST['email']) && empty($_POST['email']))

{

    $error[] = "Post your e-mail address";

}

if(isset($_POST['message']) && empty($_POST['message']))

{

    $error[] = "Post your comments";

}

if(is_array($error))

{

    echo("errors:

");

    foreach($error as $x => $i)

    {

        echo("- ".$i."

");

    }

}

else

{

    $to = "[email protected]";

    $subject = "subject";

    $message = $_POST['message'];

    $name = $_POST['name'];

    $from = $_POST['email'];

    mail($to, $subject, $message, "From: $name<$from>");

    echo("<script>alert(\"Thanks!\E-mail has been sent!\");</script>");

   

}

?>

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/57653-contact-form/page/3/#findComment-299092
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.