Web Design Forum  
 
Go Back   Web Design Forum > Web and Graphic Design > Web Design

Reply
 
LinkBack Thread Tools Display Modes
Old 08-12-2008, 02:11 AM   #1 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 17
Default Anybody have a form script?

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
Cicio is offline   Reply With Quote
Old 08-12-2008, 02:40 AM   #2 (permalink)
joe
Bronze Member
 
Join Date: Aug 2008
Location: Dallas, Tx
Posts: 83
Default

What scripting language are you wanting it in? PHP? ASP?
joe is offline   Reply With Quote
Old 08-12-2008, 02:51 AM   #3 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 17
Default

xml is fine
Cicio is offline   Reply With Quote
Old 08-12-2008, 05:00 AM   #4 (permalink)
joe
Bronze Member
 
Join Date: Aug 2008
Location: Dallas, Tx
Posts: 83
Default

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 is offline   Reply With Quote
Old 08-12-2008, 05:28 AM   #5 (permalink)
Silver Member
 
Join Date: Aug 2008
Posts: 102
Default

You could use php html and xml to create a form script but not xml by its self.
walkingbird is offline   Reply With Quote
Old 08-12-2008, 05:46 AM   #6 (permalink)
Moderator
 
jnjc's Avatar
 
Join Date: Jun 2008
Posts: 365
Default

Check out this thread, it contains links to sites that will do most of the work for you.....

contact us form
jnjc is offline   Reply With Quote
Old 08-12-2008, 05:21 PM   #7 (permalink)
joe
Bronze Member
 
Join Date: Aug 2008
Location: Dallas, Tx
Posts: 83
Default

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 = "who@where.com";

  #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>
joe is offline   Reply With Quote
Old 08-13-2008, 06:37 PM   #8 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 17
Default

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
Cicio is offline   Reply With Quote
Old 08-13-2008, 06:51 PM   #9 (permalink)
AE7
Bronze Member
 
AE7's Avatar
 
Join Date: Jul 2008
Posts: 51
Default

Quote:
Originally Posted by Cicio View Post
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..
__________________
IE Bugs are compensated for with extra code

My username is not intended to be the acronym for After Effects 7
AE7 is offline   Reply With Quote
Old 08-13-2008, 07:04 PM   #10 (permalink)
joe
Bronze Member
 
Join Date: Aug 2008
Location: Dallas, Tx
Posts: 83
Default

Quote:
Originally Posted by Cicio View Post
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.
joe is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:31 AM.


Computer Forum - TechZine - Webpage Design

 
Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.