PDA

View Full Version : Creating and Retrieving form information


db2six9
03-01-2007, 12:23 PM
I am sorry if I dont include enough information here but I am looking for some direction in creating a contact form and how to retrieve that inforation. Specifically I am trying to re-create something close to this form.

http://junctioncity.org/cvb/SubmitEventForm.htm

Please understand that this site is not mine and I had nothing to do with its creation. Deplorable.

I am using dreamweaver and I know how to create a form with all the fields, radio buttons etc., but I dont know how to retrieve this info, or if the form needs a special tag (like index, but for forms?)

Is there a way to have the info directly e-mailed, or is it all uploaded to the server? I have no knowledge on this topic so please be gentle.

Thanks

ahallicks
03-01-2007, 01:37 PM
To use a form you need an 'action' element in the form tag. This will load a file once submit is clicked that will do exactly what is in that action file. The syntax would be:

<form method="get" action="/email.php">

I've used php as a method here. Then for each of the form fields (ie. <input type="text" name="firstname" />) you need to tell the browser what to do with it. For example, in a php for you'd have to create some variables:

$firstname = $_REQUEST['name'] ;

which finds whatever is in the 'firstname' labelled field and turns it into 'name' which can then be used to E-Mail that information, or whatever else you want to do with it.

If you want to use a php form this tutorial (http://www.thesitewizard.com/archive/feedbackphp.shtml) will guide you through the process.

karinne
03-01-2007, 01:38 PM
You'll need to use a server-side language like PHP or ASP.

HTML alone won't do this for you. You can have the info sent to by email and stored in a datase if you want or just one or the other.

If you want the stuff sent to an email, here's a php contact script (http://www.joe2torials.com/view_tutorial.php?view=68) I've used a few times that pretty good.

hth

harbingerOTV
03-01-2007, 01:42 PM
the best route is to use asp or php. you need code on the back end to process the information from the form.


<form name="" method="post" action="something.php">


the blue line is a link telling the form to use that file to process after submit.
It depends on what your host has as to whehter you can use php or asp. Depending on that there are alot of forms out there for free and several in the ephp/asp forums here.

ahallicks
03-01-2007, 02:16 PM
Here's an example of a form I built in php...

the form is at http://eurobudo.co.uk/feedback.php

And if you view http://eurobudo.co.uk/sendmail.php you'll see the php script that reads the form and E-Mails it to whoever...

karinne
03-01-2007, 02:35 PM
You're gonna have to post the code 'cause since php gets parsed by the server ... we can't see the script ;)

ahallicks
03-01-2007, 02:45 PM
Dammit, just noticed that wen I tried it myself! :p


<?php

$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$topic = $_REQUEST['topic'] ;
$message = $_REQUEST['message'] ;
$oureamil = '';
$theemail = "Feedback Topic: $topic\n\n$message\n\nFrom: $name \nE-Mail: $email";

$headers = '';
$headers .= 'From: "Eurobudo Feedback" <'.$email.'>'."\r\n";
$headers .= "To: ".$email."\r\n";
$headers .= "Reply-To: ".$ouremail."\r\n";
$headers .= "Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n";

if (empty($name) || empty($topic) || empty($message)) {
header( "Location: error.php" );
}
else {
mail( "youremail", "$topic by $name", $theemail, $headers, "no-reply@eurobudo.com");
header( "Location: feedback_thanks.php" );
}

?>

CFMaBiSmAd
03-01-2007, 02:59 PM
By placing the $email variable into the header field, without testing it, will allow email header injection and will allow a spammer who finds your code to send spam to anyone he wants.