Anybody have a form script?

Cicio

New Member
Anybody have a simple form script i can use for my site? It's just a standard Name, Email, Address, Telephone and Comments box. I try to build it with DW MX 2004 but the title keeps ending up on the right of the text box.

Any help appreciated
 

joe

New Member
xml to my knowledge is not for creating a form script. You'll need html to create the form and then either php, asp, jsp, or some other server side language to interpret it and do with it what you want. What exactly are you wanting to do with the information you receive from the form?
 

joe

New Member
Here's one in php. It will send an e-mail to where you want. You should change it up to fit what you're wanting it to do.

Code:
<html>
<head><title>Feedback Form</title></head>
<body>

<?php

$self = $_SERVER['PHP_SELF'];
$username = $_POST['username'];
$useraddr = $_POST['useraddr'];
$comments = $_POST['comments'];
$userpostaladdr = $_POST['userpostaladdr'];
$telnum = $_POST['telnum'];
$sent = $_POST['sent'];


#the HTML form that can be written dynamically
$form ="<form action=\"$self\" method=\"post\">";
$form.="Name:<input type=\"text\" name=\"username\"";
$form.=" size=\"30\" value=\"$username\" ><br/><br/>";
$form.="Email:<input type=\"text\" name=\"useraddr\"";
$form.=" size=\"30\" value=\"$useraddr\"><br/><br/>";
$form.="Address:<input type=\"text\" name=\"userpostaladdr\"";
$form.=" size=\"100\" value=\"$userpostaladdr\"><br/><br/>";
$form.="Telephone:<input type=\"text\" name=\"telnum\"";
$form.=" size=\"30\" value=\"$telnum\"><br/><br/>";
$form.="Comments:<textarea name=\"comments\" cols=\"30\" rows=\"5\">";
$form.="$comments</textarea><br/>";
$form.="<input type=\"submit\" name=\"sent\" value=\"Send Form\">";
$form.="</form>";

if($sent)
{
  #set variable default value
  $valid=true;

  #check username field is not blank
  if( !$username )
  { $errmsg.="Enter your name...<br />"; $valid = false; }

  #check email useraddr field is not blank
  if( !$useraddr )
  { $errmsg .="Enter your email address...<br />"; $valid = false; }

  #check email userpostaladdr field is not blank
  if( !$userpostaladdr )
  { $errmsg .="Enter your postal address...<br />"; $valid = false; }
  
    #check email telnum field is not blank
  if( !$useraddr )
  { $errmsg .="Enter your telephone number...<br />"; $valid = false; }
  
  #check comments field is not blank
  if( !$comments )
  { $errmsg.="Enter your comments...<br />"; $valid = false; }

  #check validity of email format
  $useraddr = trim($useraddr);
  #permitted patterns for name,domain and top-level domains
  $_name = "/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+";
  $_host = "([-0-9A-Z]+\.)+";
  $_tlds = "([0-9A-Z]){2,4}$/i";
  if( !preg_match( $_name."@".$_host .$_tlds,$useraddr ) )
  { 
    $errmsg.="Email address has incorrect format!<br />";
    $valid=false;
  }
}

#if not valid write the error message/s and repeat the form
if($valid != true)
{
  echo( $errmsg.$form );
}
else
#if the form is valid send the email
{
  #recipient's email address
  $to = "[email protected]";

  #subject of the message
  $re = "Feedback from $username";

  #message from the feedback form
  $msg = "Feedback Info:";
  $msg.= "\r\n";
  $msg.= "Postal Address:  ";
  $msg.= $userpostaladdr;
  $msg.= "\r\n";
  $msg.= "Telephone Number:  ";
  $msg.= "\r\n";
  $msg.= $telnum;
  $msg.= "\r\n";
  $msg.= "Comments:";
  $msg.= "\r\n";
  $msg.= $comments;

  #set the Content-type header for HTML mail
  $headers  = "MIME-Version: 1.0\r\n";
  $headers .= "Content-type: text/html;";   
  $headers .= "charset=\"iso-8859-1\"\r\n";

  #set the From header
  $headers .= "From: $useraddr \r\n";

  #send the email now...
  if(mail($to,$re,$msg, $headers))
  { echo("Your comments have been sent - thanks $username");}

}
?>

</body></html>
 

Cicio

New Member
thanks alot Joe. I'm gonna see if I can get a buddy to help me fit it into my site cus I'm still getting some small errors I can't figure out
 

AE7

New Member
thanks alot Joe. I'm gonna see if I can get a buddy to help me fit it into my site cus I'm still getting some small errors I can't figure out

I can manipulate it for you if needed...

You could also use Flash and PHP for a form..
 

joe

New Member
thanks alot Joe. I'm gonna see if I can get a buddy to help me fit it into my site cus I'm still getting some small errors I can't figure out

You're welcome...it might need a bit more tweaking than what I put in it. I work day in and day out with asp, so I'm a bit rusty with php (different concatination opperators in this case). I just pulled that from a site I know of and added the additional requirements.
 
Top