NameSilo

{Wanted} Simple Contact form

Spaceship Spaceship
Watch
Hey

i am looking for a simple php form that I can intergrate with my site. Must include the following:

name
email
comments

I would like the bit were i add my email to come in a seperate file like a config.php file so I can easily change it when necessary.

Paying $5 for a custom script :)

j
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Why not google it, there are thousands of sites that offer you this code?

Seems a waste of $5 to me mate.
 
0
•••
want one for my site without having to leave credits for others ;)
 
0
•••
How about I just write one on the spot?

contact.php
PHP:
<html>
<head>
<title>Contact</title>
</head>

<body>

<form method="post" action="contact.php">
Name: <br>
<input type="text" name="name"><br><br>
Email: <br>
<input type="text" name="email"><br><br>
Comments: <br>
<textarea name="comments" rows="10" cols="40"></textarea><br><br>
<input type="submit" name="submit" value="Submit">
</form>

<?php

if(isset($_POST['submit']))
{
  //Let's Go ahead and include our config file containing the contact email
  include("config.php");
  
  //Grab all the data
  $name = trim(stripslashes($_POST['name']));
  $email = trim(stripslashes($_POST['email']));
  $comments = trim(stripslashes(strip_tags($_POST['comments'])));
  $comments = wordwrap($comments, 70, "<br>\n");

  //Check that the email is valid
  //Note: only checks the email for the _correct_ format "[email protected]".
  //This doesn't necessarily mean it's a real email...heh
  $validate = preg_match('/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/', $email);
  
  if(!$validate)
  {
    echo '<br>'.$email.' is not a valid email.<br>';
    exit();
  }
  else
  {
    $e = $email;
  }
  
  //Check to make sure none of the fields are empty
  if(!$name || !$e || !$comments)
  {
    echo '<br>All fields required, please enter all data.<br>';
    exit();
  }
  else
  {
    //Commence to sending the form =)
    //To send HTML mail, we'll need to set the Content-type header
    $headers  = 'MIME-Version: 1.0'."\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
    $headers .= 'From: '.$e."\r\n";
    
    //Ok, now e-mail
    $send = mail($contact_email, "Message from: $name", "

    <html>
    <head>
    <meta http-equiv=\"Content-Language\" content=\"en-us\">
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
    <title>Message from $name</title>
    </head>

    <body>
    <table cellpadding=\"2\" cellspacing=\"0\" width=\"400\" border=\"1\" style=\"border-collapse: collapse\">
    <tr>
      <td width=\"87\"><b>Name:</b></td>
      <td width=\"313\"> $name</td>
    </tr>
    <tr>
      <td width=\"87\"><b>Email:</b></td>
      <td width=\"313\"> $e</td>
    </tr>
    <tr>
      <td width=\"87\"><b>Comments:</b></td>
      <td width=\"313\"> $comments</td>
    </tr>
    </table>

    </body>
    </html>", $headers);
    
    if($send)
    {
      echo '<br>Thank you '.$name.' for contacting us.<br>';
    }
    else
    {
      echo '<br>Sorry, your message could not be sent at this time.<br>Please try again later.<br>';
    }
  }
}
//And that is all =) Very simple really.
?>

</body>
</html>

config.php
PHP:
<?php

$contact_email = "[email protected]";

?>

That should do the trick =)


-Eric
 
Last edited:
0
•••
will this do?

will this do?
no garantees though
if it does work, i'm charging nothing for it
if it doesn't... well it doesn't :)
and i hope u find something that does
but it wont!

you're prob better off using sv's
 
0
•••
SV - PM me your paypal bro ;)
 
0
•••
1
•••
0
•••
Another good free one where you don't need to leave the credits is www.noviceform.com :)

-Josh
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back