PDA

Click to See Complete Forum and Search --> : Forms in CSS?


tm_nootgroup
05-17-2005, 04:28 PM
...

Dakota1
05-17-2005, 04:33 PM
http://www.mompswebdesign.com/html/form_css.html

EC
05-18-2005, 10:06 PM
Try hotscripts.com

ecsyle
05-18-2005, 10:06 PM
Yeah, CSS wont do that.
CSS is for styling and formatting only.

What you want is to learn some PHP (http://www.php.net/).
Build your form, and use a PHP script to handle the form data.

Here is a quick form that I have been playing with at work from time to time-
click for working verison (http://web1.greatbasin.net/~ecsyle/webform.php)

<style>
.form_required{
color:#FF0000;
font-weight:bold;
}
.form_error{
border:1px dotted #636363;
background-color:#f3f3f3;
color:#646464;
font-weight:bold;
padding:10px;
margin:3px;
}
</style>
<?php
//setup form
$showform=true; //define form as true- we use this to show the form until we send the email
$mailto = "your@email.com";
$subject = "Contact Form: New Message";

//function cleanForm - strip tags and trim - could be, and should be, updated to more versatile
function cleanForm($value){
$value = trim(strip_tags($value));
return $value;
}

if(isset($_POST['contact'])) //if we clicked submit, start processing form
{
//check for required fields

/*
to require another field, copy paste the if statement and change the post value and error message.
if (empty($_POST['value'])) {
$error[]="Error message here";
}
*/
if (empty($_POST['name'])) {
$error[]="Please enter your name.";
}
if (empty($_POST['email'])) {
$error[]="Please enter a valid email address.";
}
if (empty($_POST['comments'])) {
$error[]="Please enter your comments or suggestions.";
}

//clean up fields - we are removing all html from the fields
$name = cleanForm($_POST['name']);
$email = $_POST['email'];
$title = cleanForm($_POST['title']);
$company = cleanForm($_POST['company']);
$address = cleanForm($_POST['address']);
$city = cleanForm($_POST['city']);
$state = cleanForm($_POST['state']);
$zip = cleanForm($_POST['zip']);
$comments = cleanForm($_POST['comments']);
//create message
$message = "
name - $name
email - $email
title - $title
company - $company
address - $address, $city, $state $zip
comments - $comments
";
$headers = "From: $email\r\n"; //show mail as being sent from sender, and not localhost
//check for errors during processing. if no errors, send email
if(isset($error)){
$required="<span class=\"form_required\">*</span>";
print"<div class=\"form_error\">";
foreach($error as $line){
print "$line<br />";
}
print"</div>";
}else{
mail($mailto, $subject, $message, $headers);
print"<h1>Thanks $name, your message has been recieved.</h1>";
$showform=false;
}
}
if($showform == true)//if form is true, show the contact form
{
?>

<form action="" method="post" enctype="multipart/form-data">
<table>
<tr>
<td align="right"><?=$required?>Name: </td>
<td><input type="text" name="name" value="<?=$_POST['name']?>" /></td>
</tr>
<tr>
<td align="right">Title: </td>
<td><input type="text" name="title" value="<?=$_POST['title']?>" /></td>
</tr>
<tr>
<td align="right">Company: </td>
<td><input type="text" name="company" value="<?=$_POST['company']?>" /></td>
</tr>
<tr>
<td align="right">Address: </td>
<td><input type="text" name="address" value="<?=$_POST['address']?>" /></td>
</tr>
<tr>
<td align="right">City: </td>
<td><input type="text" name="city" value="<?=$_POST['city']?>" /></td>
</tr>
<tr>
<td align="right">State: </td>
<td><input type="text" name="state" value="<?=$_POST['state']?>" /></td>
</tr>
<tr>
<td align="right">Zip: </td>
<td><input type="text" name="zip" value="<?=$_POST['zip']?>" /></td>
</tr>
<tr>
<td align="right"><?=$required?>Email:</td>
<td><input name="email" type="text" value="<?=$_POST['email']?>" /></td>
</tr>
<tr>
<td align="right"><?=$required?>Questions or comments: </td>
<td><textarea name="comments" rows="10" cols="40"><?=$_POST['comments']?></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="contact" value=" Contact Us " /></td>
</tr>
</table>
</form>
<?php
}
?>

Dakota1
05-18-2005, 10:38 PM
Thanks Dakota,

Although I am trying to find out how to set up, like an email form, as far as the backend of it.

First thing you need to find out is what types of mail scripts your server support.