MRwisdom12 Posted May 2, 2003 Posted May 2, 2003 Here is my dilema. I am new to PHP but trying like crazy to learn it. I use Dreamweaver to make my webpages so it does alot of the php for me. This is very nice, in that I can use this to help me understand PHP. The problem I am having is that I cannot successfully setup a form using php to send the info via email. I have tried to use the two CGI emailers from the CPanel to no avail. I liked the one (cant remember the name) that allows you to setup the format and then it sends the info in a neat TXT file. But after hours of changing parameters I gave up. I have been reading books and trying to make a PHP form email using my 2 PHP books but I cant seem to get it to work. Is it possible to use the mail() with TCH? I think so since I saw the path to the sendmail server in the CPanel. Also I have read the you must set the location of the mail server in the PHP.ini file in-order for this to work using Linux. Is this setup on the TCH servers? In the past I used Frontpage (oh I hate to say that, since I have been trying out the MFZ (MS Free Zone)) extensions as the form handlers but Dreamweaver does not have these, or atleast I dont know about them. If anyone could help me out with this I would greatly appreciate it. I am so new at PHP it seems I stumble at each step in the process until I finally get it to work. Thanks for your help Scott. Quote
matman Posted May 3, 2003 Posted May 3, 2003 Yes the mail function should work fine -- I use it extensively on my sites here at TCH. Here is how it works: http://www.php.net/manual/en/ref.mail.php If you want to paste in here the actual script(s) that are not working for you, I'd be happy to have a look. Quote
MRwisdom12 Posted May 3, 2003 Author Posted May 3, 2003 (edited) Thanks for the link. I was looking at it and I think I need to supply the default location in the mail function, but how do I do that? ><html> <?PHP $mail_to = "plainj1@bellsouth.net"; $mail_subject = "Hi There"; $mail_body = "We'll have a time PHPing"; $mail_body .= "7 pm friday night"; if(mail(mail_to, $mail_subject, $mail_body)) echo "Successfully send the email \"$mail_subject\" to $mail_to."; else echo "Failed to send the email \"$mail_subject\"." ?> </html> As you can tell this is just a test script to see if I can get it to work. My thinking was to get this working first before I tackled the forms. Basically all it does is send an email when it is run. Thanks for your help MatMan Scott Edited May 3, 2003 by MRwisdom12 Quote
elvenjess Posted May 3, 2003 Posted May 3, 2003 I am new to PHP but trying like crazy to learn it. Thats about were I am with it. Here's a tip: Go to your local book store/library and try to find "SAMS Teach Yourself PHP in 24 Hours". It is a very easy to read book that can teach you a lot in a short amount of time. Quote
MRwisdom12 Posted May 3, 2003 Author Posted May 3, 2003 I looked at that book, but I put it back for the beginners PHP 4 book by Wrox. Will go to morrow and check it out again. Does it explain sending email in forms and connecting to Databases? Quote
matman Posted May 3, 2003 Posted May 3, 2003 If this is the actual line in your script: if(mail(mail_to, $mail_subject, $mail_body)) It looks like you left out a "$" on your mail_to variable. That will DEFINTITELY not work! Oh, and the WROX book is the best. Actually, theirs usually are. Quote
elvenjess Posted May 3, 2003 Posted May 3, 2003 Does it explain sending email in forms and connecting to Databases? I'm only on hour 7 but I'll check in the Table of contents... ... ...... Ok, Hour 9 - Working with Forms, Hour 12 - Database Integration: SQL. I haven't read them yet so I can't ell you how useful they are to your purpose, but check it out. Quote
MRwisdom12 Posted May 3, 2003 Author Posted May 3, 2003 AHHH!!!!! Dude. Thanks so much for the help. That worked. I guess I was looking at the code so long that I was "seeing" the $ infront of the variable when it wasn't there. Maybe I should get a book on paying attention to detail.. Quote
MRwisdom12 Posted May 3, 2003 Author Posted May 3, 2003 Is there a way to change the from name? When I send the email it comes into my email address from Nobody@tch.com Quote
btrfld Posted May 3, 2003 Posted May 3, 2003 You can specify the FROM:, and many other things in the headers. The user comments on this link have a lot of examples. I've found them useful. Quote
bethohio3 Posted May 5, 2003 Posted May 5, 2003 I hate WROX books. And WROX is also going out of business and not supporting their books. I have Professional PHP Programming. I emailed them to get the code listings, and received return email that they weren't supporting anything anymore as they were no longer going to be in business. --Beth Quote
matman Posted May 5, 2003 Posted May 5, 2003 Wow, I'm disappointed to hear that. For the last four years or so they've been publishing the best programming books on the planet IMHO. Quote
MRwisdom12 Posted May 5, 2003 Author Posted May 5, 2003 I saw that book at Banes and Nobles bethohio3. (Professional PHP programming). I leafed through it at the store for about 15 minutes, and first of all it was over my head in php programming, but I did feel like that particular book was as "neat" as the beginning PHP 4 book that I have. It seemed to jump all over the place. That is of course IMHO. I do like the other Wrox books as well. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.