Page 1 of 1

Contact us form

Posted: Thu Oct 03, 2002 11:10 am
by webcreator
I'm a young developer and I'm having trouble creating a contact form, can some one please help me regarding this matter. I have tried to creat them but not good. I'm able to alter coding but have had no real luck in creating a from page from scratch.

:D

Posted: Thu Oct 03, 2002 11:32 am
by mydimension
can you show us what you have so far? someone here may be able to give you a few pointers to getting your code to work :)

Posted: Thu Oct 03, 2002 4:36 pm
by mr_griff
Here is a little script that I use as a quick fix for mailing a contact for to someone. Not much built in for formatting, but it gets the job done.

This script is setup to atleast have two fields named "name" and "email". It will accept any other form fields that are posted to the page also.

Code: Select all

<?php
$mailBody = "";

while (list($key, $value) = each($_POST))
{
  $mailBody .= $key . ": " . $value . "\n";
}

if ($_POSTї"name"] != "" || $_POSTї"email"] != "")
{
  if ($_POSTї"name"] == "")
  {
    $name = "No Name Given";
  }

  if ($_POSTї"email"] == "") 
  {
    $email = "no_email_address@mydomain.com";
  }

  mail("you@yourdomain.com", "Website Comments", "$mailBody", "From: $name <$email>");
}
?>