hi...I am just trying to learn php, and I have the basic stuff, but can someone please show me the script so that I can use a submit form, and it will e-mail straight to my e-mail address?...if there is a way....
Thankyou
Printable View
hi...I am just trying to learn php, and I have the basic stuff, but can someone please show me the script so that I can use a submit form, and it will e-mail straight to my e-mail address?...if there is a way....
Thankyou
knock yourself out
http://www.thickbook.com/extra/php_email.phtml
thanks a lot, but that stuff just confused me even more....and i don't understand what action="contact.php" I don't understand what that is for....I want a script that will e-mail it straight to my e-mail address without that contact.php thing
action="contact.php" is telling the form what to do. like its saying
"okay, heres what the user entered, now i'll give it to contact.php and he can do the emailing work"
you need action="contact.php" if you want the form to do anything at all. you can do it all in one file but i remember when i learned all this crap (not very long ago) and i can tell you that its 100% easier with 2 files.
well, you said you wanted to learn PHP, you posted it in a php forum, therefore I was assuming you wanted to use php to process your form and email it to you...:confused:Quote:
Originally posted by Little Ant
thanks a lot, but that stuff just confused me even more....and i don't understand what action="contact.php"
No it's not. There's no reason you'd need 2 files for this. Somthing like:Quote:
Originally posted by DJ P@CkMaN
you can do it all in one file but i remember when i learned all this crap (not very long ago) and i can tell you that its 100% easier with 2 files.
Will do.Code:<?php
if (isset($_REQUEST['submit'])) {
mailform();
} else {
sendmessage();
}
function mailform() {
echo '<html>
<head>
<title>Send Mail</title>
</head>
<body>
<form action="contact.php" method="post">
<b>Your E-mail</b>: <input type="text" name="email"><br>
<b>Message</b>:<br>
<textarea name="message"></textarea><br>
<input type="submit" value=" Send Mail ">
</form>
</body>
</html>';
}
function sendmessage() {
string to, string subject, string message [, string additional_headers [, string additional_para
mail("[email protected]", "User Feedback", $_REQUEST['message'], "From: " . $_REQUEST['email']);
echo 'Your message has been sent!';
}
?>
thanx a lot, you have all been a lot of help. I want to learn php, but that shoved too much information in my face at once. Thanx to all of you who reply'd to me with help.
I just tried the script you gave me 'the hobo', and it didn't seem to work, none of the <input> showed up. If you could help me with this i would be grateful
thanx
The Hobo: I said that it _CAN_ be done with one page and I know how to do it, it's not hard, but for a beginner, doing it with two files is easier to understand.
Do you have everything set up, to be able to run PHP. Do you have server software. PHP software?Quote:
Originally posted by Little Ant
I just tried the script you gave me 'the hobo', and it didn't seem to work, none of the <input> showed up. If you could help me with this i would be grateful
thanx
Because without you cant do anything.
it is all working now, however, for my contact.php page, it won't send the e-mail....it show what i have typed and does everything it is supposed to, except send the actual e-mail. this is the script I have so far....if you can notice any faults...please tell me.
<?php
$comment = stripslashes($comment);
$YourEmail = "[email protected]";
if (!$name) {echo "You must enter your name,<BR>Please go back and make corrections.<BR> Thank you"; } else {
if(!$email == "" && (!strstr($email,"@") || !strstr($email,"."))) {echo "You must enter a VALID Email Address,<BR> Hit the back button and enter your email address."; } else {
if (!$email) {echo "Email Field was empty, please enter your email."; } else {
if (!$comment) {echo "You must leave a comment.<BR>Go back and enter your comment"; } else {
if (!$fav_script) {echo "Choose your Favorite Script"; } else {
PRINT "<FONT SIZE=-1 face=verdana>";
PRINT "$name, Thank-you very much!!";
PRINT "<HR>";
PRINT "<B>Information Sent Via Email:</b>";
PRINT "<br><BR>";
PRINT "Name: $name";
PRINT "<BR>";
PRINT "Email: $email";
PRINT "<BR>";
PRINT "Favorite Scripting Technology: $fav_script";
PRINT "<BR>";
PRINT "Comments:$comment";
PRINT "<HR>";
PRINT "<B><a href=http://www.php50.com/circusmijit13>PLEASE CLICK HERE, To get back on our Site</a>";
PRINT "<hr>";
PRINT "</b></body>";
PRINT "</html>";
mail("$email", "Thanks For Your Email", "
Thank-you $name,
\nYou filled out our E-mail Form.\nThe Information that was submitted was:
\nName:$name\nEmail:$email\nFavorite Scripting Technology: $fav_script
Comment: $comment\n\nRegards,\nNick\nwww.realgoodhosting.com");
mail("$YourEmail", "Email Form Result", "
From: $name,
\n$name filled out our E-mail Form.\nThe Information that was submitted was:
\nName:$name\nEmail:$email\nFavorite Scripting Technology: $fav_script
Comment: $comment\n\nRegards,\nWebMaster\nwww.realgoodhosting.com");
}
}
}
}
}
?>
Do you get any errors? what webserver software are you running IIS or Apache? If one problem may be that you have not configured it stmp mail in order for a script to send mail.
I get no errors, It shows me what it is supposed to, but how do I set up 'stmp mail'?
If you're on Windows (2000 or XP) then you can do
Start->Setttings->Control Panel->Add/Remove Programs->Add/Remove Windows Components->Select Internet Information Services (IIS)->Click Details...->Check SMTP Service->OK->Next->Next->Finish
If you're on Linux or Unix, then you probibly have one setup already - sendmail.
Alternatively you may be able to use your ISP's mail server - this depends on the ISP. Doing this is called "relaying" and they may not take kindly to it.
Once you have an SMTP Mail Server setup, you need to tell PHP where it is.
On Windows, click Start->Run, type in php.ini and hit enter. It should open in Notepad.
On Linux/Unix you'll have to find it using whereis.
Once it is open, scroll down to the bit like:
If your server is Windows based, uncomment (remove the ; at the start) the SMTP line, and change localhost to be the fully qualified host name or IP address of the SMTP server. This may be something like mail.myisp.com or localhost if it's on the same machine that is running PHP. Next uncomment the sendmail_from line and replace [email protected] with your e-mail address.Code:[mail function]
; For Win32 only.
;SMTP = localhost
; For Win32 only.
;sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: 'sendmail -t -i').
;sendmail_path =
Or if your server is Linux/Unix, uncomment the sendmail_path and set it to the full path to sendmail along with any command line paramaters necessary like /usr/sbin/sendmail -t -i
Now close php.ini and save it.
With any luck as long as your SMTP server can see the Internet and the server running PHP, your script should be able to send e-mails.