Google is your Friend
With the help of google and the most wonderful online php manual linky I managed to hand code a mailing system attached to a form in my assignment that has to be handed in tonight.
If your having trouble with your php scripting give this site a go. Work through it methodically and you will get there in the end.
I lurrrrrrrrrrv google. :blush:
My simple script
<?php
$email = $_REQUEST['email'] ;
$fullname = $_REQUEST['fullname'] ;
$message = $_REQUEST['message'] ;
$telephone = $_REQUEST['telephone'] ;
$findsearch = $_REQUEST['findsearch'] ;
$findword = $_REQUEST['findword'] ;
$findother = $_REQUEST['findother'] ;
$age = $_REQUEST['age'] ;
$selectcat = $_REQUEST['selectcat'] ;
$to = $email;
$subject = 'Thank You';
$body = "Thank you for contacting Paradise Regained. Your catalogue will be sent to you electronically when the office next opens.\n\n".
"This is an automated response. Please do not reply to this email\n\n".
"The Webmaster";
$headers = 'From: youremail.co.uk' . "\n" . 'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $body, $headers);
$to = "youremail.co.uk";
$subject = 'Catalogue Request';
$body = "name: $fullname\n".
"email: $email\n".
"Telephone: $telephone\n".
"age: $age\n".
"message: $message\n\n".
"catalogue: $selectcat\n".
"Found in search engine: $findsearch\n".
"Found by word of mouth: $findword\n".
"Found by other: $findother";
$headers = 'From: youremail.co.uk' . "\n" . 'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $body, $headers);
header( "Location: thankyou.html" );
?>
Waddaya think of my baby - simple but effective
mag's
Newbie webmaster
Remember - Google is your friend!
Busy posted this at 09:19 — 8th March 2006.
He has: 6,151 posts
Joined: May 2001
Instead of _REQUEST use _POST, will stop BBC injections, also some validation on email address should be done for same reason.
good on ya
Magnolia posted this at 17:19 — 8th March 2006.
They have: 60 posts
Joined: Feb 2006
Thanks Busy - I will look at _POST and see what it does. I did forget to say that the form has a validation script on it before the submit button will work.
mag's
Newbie webmaster
Remember - Google is your friend!
Busy posted this at 21:42 — 8th March 2006.
He has: 6,151 posts
Joined: May 2001
_post = from a form internally
_get = from a form via url (?this=that&do=stuff)
_request = _get, _post, _session ...
A good way to learn/use the mail function is contact form (of course), tell a friend, complain/advise/contact a seperate department depending on topic (use drop down list to choose who and with use of SWITCH change the subject, message and even autoreply message) ...
Can also use it for database query faults (if(!$db) send mail), not advised to do this, but if you want to, set it up as a function and return the function on error, this way if the server or host is at fault you can disable the function, which will stop all email once you get your first thousand lol (yeah happened to me once, finally got them all disabled after getting 1700 emails)
Magnolia posted this at 07:45 — 9th March 2006.
They have: 60 posts
Joined: Feb 2006
I can see the error in the ways of this
This is an assignment for my course so it will never be used in real time. I am a hobby user who is just creeping in at the very bottom with no knowledge apart from a little common sense - and I do mean a little
I will sit and work through your suggestions this weekend. I know so little that at first glance it didnt mean a great deal but breaking it down and with the help of my friend google I will learn more and improve my scripting
Thanks again for your help and comments.
Oh yes - next week we are moving onto MySQL :eek:
mag's
Newbie webmaster
Remember - Google is your friend!
Busy posted this at 09:24 — 9th March 2006.
He has: 6,151 posts
Joined: May 2001
Good luck, with assignments they only usually cover the basics, but you are on the right track learning from the source.
If you do get stuck or don't understand just ask away, plenty of folks ready to offer friendly advice to help you out.
Learning from your mistakes is good, finding that missing ; or ' or " can cause nightmares but helps you to not do it again in a hurry lol
Magnolia posted this at 18:23 — 9th March 2006.
They have: 60 posts
Joined: Feb 2006
or not putting the php after the ?> when using a linux server which doesnt require it and then moving it to another server which does - just makes your heart sink
Found it in the end though - took me all of oooooo over an hour
mag's
Newbie webmaster
Remember - Google is your friend!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.