creating a form problem
#1
Posted 21 December 2005 - 01:09 PM
www.retrodesigner.co.uk/contact.html
i selected the fields and set it up following a guide but when i click n the send button it just opne my mail client and none of the data inputted is there. not sure where i have gone wrong
and is there anway improve the look of he boxes and line them up?
any help would be great thanks
#2
Posted 21 December 2005 - 01:49 PM
Although, the easiest way to handle contact forms is through a server-side language like PHP, which i would recommend looking into (i know there are a ton of tutorials on how to do it in the database).
And i know i'm going to get yelled at for this, but the easiest way to organize a form is with a table.
Edited by rc69, 21 December 2005 - 01:51 PM.
#3 _*Raremandan_*
Posted 21 December 2005 - 09:47 PM
But i'll post it here as you probably don't want too go reading through tutorials.
<html> <head> <title>Comments</title> </head> <body><form action="mail.php" method="post"> Your Name: <input type="text" name="name"><br> E-mail: <input type="text" name = "email"><br><br> Your Comments:<br> <textarea name="comment"></textarea><br><br> <input type="submit" value="Tell Us!"> </form> </body> </html>
Now you can change the boxes and stuff they ask etc.
And now for the basic PHP bit you must call the PHP file mail.php
<?
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['comment'];
$to="Write you email address here, it will not be visible";
$message=" $name sent you a comment on your site.\n They said $story\n\n Their e-mail address was: $email";
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Your form was succsessful, write what you want here";
} else {
echo "The form didn't send, you can write some kind of messege here when your form has failed.";
}
?>
Now I edited the form so it tell you exactly where too put your e-mail address.
Good luck
- Dan
#4
Posted 03 January 2006 - 07:38 AM
Thanks for the help, i have just got round to trying that and it works, just a few questions though, hope you or someone can help me.
1-when the send button is pressed i get a message saying it has been sent bu this just opens on a blank page with the text and then there is no option to go back to the site, is it possible to have the message go to a page of the site?
2- in the PHP file there is an option for if there is an error but when tested i can leave some section of the form empty and it still sends, so theerror message does not work, is it possible to set the form up so that if a section is not completed that the form will not send?
any help would be great, thanks
#5
Posted 03 January 2006 - 09:05 AM
if you want to redirect them replace this
echo "Your form was succsessful, write what you want here";with this
header('location: succespage.php');
====2. The form is send no matter what, because there is simply NO error checking.
#6
Posted 03 January 2006 - 09:43 AM
Avalanche, on Jan 3 2006, 02:05 PM, said:
if you want to redirect them replace this
echo "Your form was succsessful, write what you want here";with this
header('location: succespage.php');
====2. The form is send no matter what, because there is simply NO error checking.
ihave just had a look at that,
i changed my line to
header('location: aboutrd.html');
but i still seem to load up the original page, this can be viewed at http://www.retrodesi...uk/contact.html
#7
Posted 03 January 2006 - 02:48 PM
#8
Posted 04 January 2006 - 07:22 AM
Avalanche, on Jan 3 2006, 02:05 PM, said:
if you want to redirect them replace this
echo "Your form was succsessful, write what you want here";with this
header('location: succespage.php');
====2. The form is send no matter what, because there is simply NO error checking.
#9
Posted 04 January 2006 - 09:58 AM
<?
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['comment'];
$to="Write you email address here, it will not be visible";
$message=" $name sent you a comment on your site.\n They said $story\n\n Their e-mail address was: $email";
if(!empty($name) || !empty($email) || !empty($comment)){
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Your form was succsessful, write what you want here";
}
} else {
echo "PLEASE FILL IN ALL FIELDS!!!!!!.";
}
?>
edit: fixed a parse error
Edited by Avalanche, 04 January 2006 - 09:58 AM.
#10
Posted 04 January 2006 - 10:49 AM
Avalanche, on Jan 4 2006, 02:58 PM, said:
<?
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['comment'];
$to="Write you email address here, it will not be visible";
$message=" $name sent you a comment on your site.\n They said $story\n\n Their e-mail address was: $email";
if(!empty($name) || !empty($email) || !empty($comment)){
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Your form was succsessful, write what you want here";
}
} else {
echo "PLEASE FILL IN ALL FIELDS!!!!!!.";
}
?>
edit: fixed a parse error
is that that i need to add the last echo command?
whats a parse error?
thanks
#11
Posted 04 January 2006 - 12:09 PM
if(!empty($name) || !empty($email) || !empty($comment)){
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Your form was succsessful, write what you want here";
}
it simply checks if the fields are NOT empty, if they are not, the form will be send, else it will echo the error
#12
Posted 04 January 2006 - 12:11 PM
i will make the changes thanks
#13
Posted 04 January 2006 - 02:45 PM
#14
Posted 04 January 2006 - 04:32 PM
#15
Posted 04 January 2006 - 04:40 PM
<?
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['question'];
$to="enquiries@retrodesigner.co.uk";
$message=" $name sent you a comment on your site.\n They asked $question\n\n Their e-mail address was: $email";
if(!empty($name) || !empty($email) || !empty($comment)){
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Your form was succsessful, write what you want here";
}else {
echo "Sorry, there was a problem with your question please try again.";
}
?>
#16
Posted 04 January 2006 - 04:43 PM
if(!empty($name) || !empty($email) || !empty($comment)){
// Needs to be
if(!empty($name) && !empty($email) && !empty($comment)){
Edited by rc69, 04 January 2006 - 04:44 PM.
#17
Posted 04 January 2006 - 04:52 PM
#18
Posted 04 January 2006 - 05:30 PM
#19
Posted 06 January 2006 - 03:56 AM
Parse error: parse error in /home/httpd/vhosts/retrodesigner.co.uk/httpdocs/mail.php on line 24
which seems odd as there is no line 24.
Any Ideas?
cheers.
RESULT: after it not working i have just scrapped that file and started agin from the top of this post and although i am sure i just copied an pasted last time, this time when i have copied it it seems to work, so thanks for all your help guys much appreciated.
ARGH!!!!
now the form wont return to a webpage when form is sent.
here is my code, what is wrong? please
<?
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['question'];
$to="Write you email address here, it will not be visible";
$message=" $name sent you a comment on your site.\n They said $story\n\n Their e-mail address was: $email";
if(!empty($name) && !empty($email) && !empty($question)){
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
header('location: index.html');
}
} else {
header('location: contact.html');
}
?>
Edited by donkeymusic, 06 January 2006 - 04:10 AM.
#20
Posted 06 January 2006 - 06:28 AM
try meta refresh instead
echo '<meta http-equiv="refresh" content="0;url=index.html">'; exit();
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
