Forms

This is a discussion on "Forms" within the Web Page Design section. This forum, and the thread "Forms are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 8th, 2007, 14:43
crackafaza's Avatar
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 453
Thanks: 1
Thanked 3 Times in 3 Posts
Send a message via MSN to crackafaza
Forms

Hi all!
I apologise now because I know I am in the wrong place, but o well here goes my problem!
I no how to create a simple form, but how do you encorporate that so that somebody on a website can fill in information and then press a submit button and then that information is sent to my email account?
please help!

Many Thanks
Cracka
Reply With Quote

  #2 (permalink)  
Old Aug 8th, 2007, 14:53
1840dsgn's Avatar
SuperMember

SuperMember
Join Date: Jun 2007
Location: Canterbury
Age: 19
Posts: 720
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Forms

you need to make the form in html...you know how to do that?

And then you have two options...well literally you have two options but really there is only one suitable solution!

Firstly you could sue dthis as the action:

Code: Select all
<form name="form1" action="mailto:user@domain.com">
this sends the contents of the form to user@domain.com, obviously replace that with your email address. BUT the suer will not get any indication of whether it was successful or not, the form page will just reload so they won't know if it sent ok, ther suer won't get any email notification, its not very secure at all.

The option you should use it to use a PHP script to send the contents of the form. With PHP you can do a load of things like validate form inputs to prevent hackers, redirect the user to a thank you page once they have submitted their data, send the user an automatic email saying your information has been successfully received, format the data sent to your emaila ddress to make it easy to read and LOADS more.

Look for PHP form tutorials and you will find loads to get you going.

Mike
Reply With Quote
  #3 (permalink)  
Old Aug 8th, 2007, 15:32
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Forms

Search the forum for contact form ... this has been answered MANY times before.
Reply With Quote
  #4 (permalink)  
Old Aug 13th, 2007, 02:16
Junior Member
Join Date: Jul 2007
Location: Arkansas, USA
Age: 21
Posts: 45
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to nashultz07 Send a message via MSN to nashultz07
Re: Forms

Here is the php code that I use, you will have to change it to fit your functions.

PHP: Select all

<?php
function clean($data) {
 
$data trim(stripslashes(strip_tags($data)));
 return 
$data;
}
$exploits "/(content-type|bcc:|cc:|document.cookie|onclick|onload)/i";
foreach (
$_POST as $key => $val) {
 
$c[$key] = clean($val);
 if (
preg_match($exploits$val)) {
  exit(
"<p>No exploits, please!</p>");
 }
}
$show_form true;
$error_msg NULL;
if (isset(
$c['submit'])) {
 if (empty(
$c['name']) || empty($c['email']) || empty($c['comments'])) {
  
$error_msg .= "Name, e-mail and comments are required fields. \n";
 } elseif (
strlen($c['name']) > 15) {
  
$error_msg .= "The name field is limited at 15 characters. Your first name or nickname will do! \n";
 } elseif (!
ereg("^[A-Za-z' -]"$c['name'])) {
  
$error_msg .= "The name field must not contain special characters. \n";
 } elseif (!
ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$",strtolower($c['email']))) {
  
$error_msg .= "That is not a valid e-mail address. \n";
 }
 if (
$error_msg == NULL) {
  
$show_form false;
  if (!empty(
$c['url']) && !ereg("^(http|https)"$c['url'])) {
   
$c['url'] = "http://" $c['url'];
  }
  
$subject "Automatic Form Email";
  
$message "You received this e-mail message through your website: \n\n";
  foreach (
$c as $key => $val) {
   
$message .= ucwords($key) . ": $val \n";
  }
  
$message .= "IP: {$_SERVER['REMOTE_ADDR']} \n";
  
$message .= "Browser: {$_SERVER['HTTP_USER_AGENT']}";
  if (
strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
   
$headers   "From: YOUR@EMAIL.COM \n";
   
$headers  .= "Reply-To: {$c['email']}";
  } else {
   
$headers   "From: HTTP://YOURSITE.COM <YOUR@EMAIL.COM> \n";
   
$headers  .= "Reply-To: {$c['email']}";
  }
  
$recipient "YOUR@EMAIL.COM";
  if (
mail($recipient,$subject,$message,$headers)) {
   echo 
"<p>Thank you! Your mail was successfully sent.</p>";
  } else {
   echo 
"<p>Your mail could not be sent at this time.</p>";
  }
 }
}
if (!isset(
$c['submit']) || $show_form == true) {
 function 
get_data($var) {
  global 
$c;
  if (isset(
$c[$var])) {
   echo 
$c[$var];
  }
 }
 if (
$error_msg != NULL) {
  echo 
"<p><strong style='color: red;'>ERROR:</strong><br />";
  echo 
nl2br($error_msg) . "</p>";
 }
?>
Last Blog Entry: First Post! (Apr 18th, 2008)
Reply With Quote
Reply

Tags
forms

Thread Tools

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms acrikey Web Page Design 13 Aug 6th, 2007 21:31
JS and Forms roki13 JavaScript Forum 1 Jun 6th, 2007 15:28
Forms nzamusangamungu Web Page Design 5 Nov 13th, 2006 13:10
forms mickc90 PHP Forum 3 Aug 1st, 2006 22:06
forms atomicant_2005 JavaScript Forum 15 Dec 9th, 2005 16:09


All times are GMT. The time now is 18:09.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43