![]() |
|
|
#1 |
|
Moderator
|
Feedback form! :-)
In this tutorial I will show you how to create a feedback form which mails the users results to you.
The best part about this is that it seems as if the user is sending the mail, his/her name and E-mail appears in the from and reply line, and you can customize your subjects. Nifty, eh? 1. Get the form ready: Well first we're going to need a form: Code:
<i>* denotes a required field</i><br /><br /> <form enctype='multipart/form-data' action='feedback.php' method='post' name='fback'> <b>*</b>Name: <input type="text" name="Name"><br /><br /> <b>*</b>E-Mail Address: <input type="text" name="Email"><br /><br /> Telephone Number: <input type="text" name="Telephone"><br /><br /> Subject: <select name="Subject"> <option>Grapes</option> <option>Bannanas</option> <option>Apples</option> <option>Peaches</option> <option>Pears</option> <option>Plums</option> </select><br /><Br /> <b>*</b>Comments: <br /><textarea name="Comments" cols="50" rows="5">Enter your comments here...</textarea><br /><br /> <input type="submit" onClick="javascript:send_if_valid()" value="Submit"> </form> For the sunject I used a drop down menu, to use a text input put this in: Code:
<input type="text" name="Subject"> To add more options to the drop-down hence adding more subject choices add this: Code:
<option>Subject value...</option> Also heres a small JavaScript E-mail address validatior: Code:
<script type="text/javascript">
//start validation
function send_if_valid()
{
if( document.fback.Email.value.indexOf("@")== -1 )
fail("No '@' in address");
else
{
var adr = document.fback.Email.value.split("@");
if(adr[0] .length < 1 ) fail("User address absent.");
else if(adr[1] .indexOf(".")== -1) fail("No dot");
else if(adr[1] .length < 3) fail("Domain incorrect");
else document.fback.submit();
}
}
//dispaly errors
function fail(msg)
{ window.alert("E-mail address error:\n" +msg); }
</script>
![]() Save as feedbackform.html Not the real work, the PHP: PHP Code:
This is needed as the file is based with some functions from that. We'll make it later. Now, theres really nothing to edit other than the message if you want to, and the E-mail address it goes to which is in the mail() function. Basically the if's just check to make sure fields aren't null and if they are it will produce some errors. Save as feedback.php Now for global.inc.php PHP Code:
Upload and acess feedbackform.html to use it! Enjoy. :-)If I did anything wrong please tell me.
__________________
| - FAQ - | - Request Format - | - HM Packages - | - ToS - | - AuP - | | - I'm Only Human! - | - TM-Software - | - Kingdoms of Battle - | |
|
|
|
|
|
#2 | |
|
Quote:
![]() Also, what exactly is the pt_register() function for/what does it do? |
||
|
|
|
|
|
#3 |
|
Moderator
|
Ah thanks for catching that mistake.
![]() pt_register() registers the thingys, makes them nifty little variables, instead of using $_POST. However, $_POST would work, I tried both.
__________________
| - FAQ - | - Request Format - | - HM Packages - | - ToS - | - AuP - | | - I'm Only Human! - | - TM-Software - | - Kingdoms of Battle - | |
|
|
|
|
|
#4 |
|
Are there any advantages to this over $_POST, or other methods of retrieving... whatever they're called?
|
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Feedback Form... | mck9235 | P. H .P | 6 | 03-14-2005 12:08 PM |