jwk811 Posted September 29, 2006 Share Posted September 29, 2006 I've been searching on here to find out how I could send mail in a form using php. It looks like all that is needed is the $mail variable, but I thought it was all more complicated than that. Here's a script that a form a found on here goes to.[code]<?phpif(isset($_POST[email])){$name=$_POST['name'];$mail_to = "name@domain.com";$mail_subject="Online Inquery Form from Peakmore.com";$mail_body = "Message Sent From: ".$name."\r\n<br />";$mail_body .= wordwrap({$_POST['emailmessage']},72,"<br />\r\n"); if (mail($mail_to, $mail_subject, $mail_body, "From:$emailaddress")){ echo "Thank you."; } else { echo "Failed to send. Please try again."; }}else{echo "You have not filled in your email address.";}?>[/code]Is that all thats needed to send mail? Please help me, thank you! Quote Link to comment Share on other sites More sharing options...
Demonic Posted September 29, 2006 Share Posted September 29, 2006 yeah for a basic email buut wheres the forum? Quote Link to comment Share on other sites More sharing options...
jwk811 Posted September 29, 2006 Author Share Posted September 29, 2006 Really? Wow. I was trying to set up some kind of email thing which was really hard, didnt know that I could just do that.. whats the difference when you say basic email? What are the disadvantages.. is there a delay before I'd recieve an email like all form processors have? I'll show you a form and I hope you can say if the script it's sent to will work or not. Could you actually show me a script I could use do send form mail? All I would need to do is replace all the input data into variables and add the mail subject and body variables, and in the body post the form data variables, correct? Which piece actually sends the mail? Quote Link to comment Share on other sites More sharing options...
Demonic Posted September 29, 2006 Share Posted September 29, 2006 try this:[code]<?php//Copy Demonic.$from = $_POST['email'];$subject = $_POST['subject'];$message = $_POST['question']."\n\n\n\n\n-------------------\n User's IP is ".$_SERVER['REMOTE_ADDR']."\n-----------------\n";if(isset($_POST['sendquestion'])){$user = explode("@", $from);mail("YOUREMAIL@SOMESITE.COM", $subject, $message, "From: " ."EMAIL NAME THING HERE - ". $user[0] . "<" . $from . ">\n");echo "YOUR MESSAGE";}else{echo"<center><form method='post'><table><tr><td><input type='text' name='email' value='Your Email'></td></tr><tr><td><input type='text' name='subject' value='Subject'></td></tr><tr><td><textarea name='question'></textarea></td></tr></table><br><input type='submit' name='sendquestion' value='Send Your Support Ticket'><br></form></center>";} ?>[/code] Quote Link to comment Share on other sites More sharing options...
jwk811 Posted September 29, 2006 Author Share Posted September 29, 2006 Could I could just add that all onto the form page without having to send the data to a script? Would I still be able to send the data to another page after that? And I not very good with this but which places should I replace and with what? And thank you very much for helping me, I really apreciate it! :) Quote Link to comment Share on other sites More sharing options...
Demonic Posted September 29, 2006 Share Posted September 29, 2006 Can you tell me exactly what you mean please. ;) Quote Link to comment Share on other sites More sharing options...
jwk811 Posted September 29, 2006 Author Share Posted September 29, 2006 [quote]Could I could just add that all onto the form page without having to send the data to a script? Would I still be able to send the data to another page after that? And I not very good with this but which places should I replace and with what? And thank you very much for helping me, I really apreciate it![/quote]In the script you wrote you have the mailing thing on the same page as the form. I thought you were supposed to direct the form to that script in a different file. And what should I replace in the script you wrote with my own things I'm going to be needing. Sorry for being unclear... ;D Thanks! Quote Link to comment Share on other sites More sharing options...
jwk811 Posted September 29, 2006 Author Share Posted September 29, 2006 And i just found this code to test out an email. How would I do this like it's just a code how will I make it work?[code]<?php$to = "somebody@example.com";$subject = "My subject";$txt = "Hello world!";$headers = "From: webmaster@example.com" . "\r\n" ."CC: somebodyelse@example.com";mail($to,$subject,$txt,$headers);?>[/code] Quote Link to comment Share on other sites More sharing options...
Demonic Posted September 29, 2006 Share Posted September 29, 2006 from that script you found edit the $to varible to your email then upload script and go to link and then check your email.And know you dont have to redirect the script to the PHP files to work.Just edit (in the script i posted):mail("YOUREMAIL@SOMESITE.COM",your email^echo "YOUR MESSAGE";^your message(this will show once you click submit to send the email)say i putecho "Your email was sent.";just letting you know nothen went wrong. :).upload the script and try it out and view your email. Quote Link to comment Share on other sites More sharing options...
jwk811 Posted September 29, 2006 Author Share Posted September 29, 2006 okay i just unloaded that php file into my ftp server. i went to the web address and this came up [code]Parse error: parse error, unexpected T_VARIABLE in /home/content/j/w/k/jwk811/html/testemail.php on line 1[/code] Quote Link to comment Share on other sites More sharing options...
Demonic Posted September 29, 2006 Share Posted September 29, 2006 please check the other topic you created. (why didnt you use the one I had?) Quote Link to comment Share on other sites More sharing options...
jwk811 Posted September 29, 2006 Author Share Posted September 29, 2006 ok because i saw that you left or your name wasnt at top so i thought you were gone and people dont usually look at the threads that have a lot of posts as in they're done and a new thread usually someone you step up to help first lol Quote Link to comment Share on other sites More sharing options...
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.