|
-
Aug 13th, 2002, 06:57 PM
#1
Thread Starter
Member
newB to php
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
-
Aug 13th, 2002, 07:29 PM
#2
PowerPoster
-
Aug 13th, 2002, 08:08 PM
#3
Thread Starter
Member
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
-
Aug 14th, 2002, 06:58 AM
#4
Lively Member
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.
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
Aug 14th, 2002, 08:57 AM
#5
PowerPoster
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"
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...
-
Aug 14th, 2002, 10:16 AM
#6
Stuck in the 80s
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.
No it's not. There's no reason you'd need 2 files for this. Somthing like:
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!';
}
?>
Will do.
-
Aug 14th, 2002, 04:05 PM
#7
Thread Starter
Member
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.
<html>
<marquee behavior="alternate" width=50%> This is a test </marquee>
-
Aug 14th, 2002, 04:13 PM
#8
Thread Starter
Member
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
<html>
<marquee behavior="alternate" width=50%> This is a test </marquee>
-
Aug 14th, 2002, 05:18 PM
#9
Lively Member
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.
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
Aug 14th, 2002, 05:46 PM
#10
Fanatic Member
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
Do you have everything set up, to be able to run PHP. Do you have server software. PHP software?
Because without you cant do anything.
-
Aug 14th, 2002, 08:59 PM
#11
Thread Starter
Member
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");
}
}
}
}
}
?>
-
Aug 14th, 2002, 09:14 PM
#12
Fanatic Member
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.
-
Aug 15th, 2002, 08:41 AM
#13
Thread Starter
Member
I get no errors, It shows me what it is supposed to, but how do I set up 'stmp mail'?
<html>
<marquee behavior="alternate" width=50%> This is a test </marquee>
-
Aug 19th, 2002, 03:05 PM
#14
Addicted Member
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:
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 =
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.
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|