Col2eight Posted September 29, 2009 Share Posted September 29, 2009 Well, I already know how. Here is my setup: $EmailFrom = "MY EMAIL"; $EmailTo = THIS IS WHERE I WANT TO INPUT EMAILS!; $Subject = "MY SUBJECT"; $Email = Trim(stripslashes($_POST['Email'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "THIS IS MY BODY TEXT"; $Body .= "\n"; $Body .= "\n"; $Body .= "ANOTHER PART OF MY BODY"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); Alright, well that's my basic setup. I just want to know how to send the email to ANY email address I want with the textbox right above the submit button (on the index.php page). I know it's hard to understand and see without actually seeing it yourself, but help me out. I have tried $Email and &_POST['Email'] and other things but still nothing. THANKS! <3 Quote Link to comment https://forums.phpfreaks.com/topic/175883-sending-e-mails/ Share on other sites More sharing options...
Alex Posted September 29, 2009 Share Posted September 29, 2009 You use the $_POST super-global. eg. $_POST['Email']; Also, just a few tips relating to your code. echo is generally better to use over print because it's faster. Another small thing is it's a better idea to use the Location option for header() over a meta refresh. eg. header('Location: error.html'); exit; Quote Link to comment https://forums.phpfreaks.com/topic/175883-sending-e-mails/#findComment-926722 Share on other sites More sharing options...
Col2eight Posted September 29, 2009 Author Share Posted September 29, 2009 I'm not gonna' lie, that confused the shit out of me. I'm new to php haha. So this doesn't make much sense. Is there just a simple fix? Like changing the $EmailTo to something certain (which would be the email I enter). Quote Link to comment https://forums.phpfreaks.com/topic/175883-sending-e-mails/#findComment-926723 Share on other sites More sharing options...
Alex Posted September 29, 2009 Share Posted September 29, 2009 Sorry if I confused you Assmusing that the name property of the input element that you want to enter the email address into is "Email" (Case matters), just make $EmailTo = $_POST['Email']; Quote Link to comment https://forums.phpfreaks.com/topic/175883-sending-e-mails/#findComment-926724 Share on other sites More sharing options...
Col2eight Posted September 29, 2009 Author Share Posted September 29, 2009 Sorry if I confused you Assmusing that the name property of the input element that you want to enter the email address into is "Email" (Case matters), just make $EmailTo = $_POST['Email']; Haha it's fine. But yeah, I already tried that. It just takes me to my error page and the email (obviously) is never sent. wait, hold on. I messed up! thanks haha. I just realized that I changed "Email" to "mail" before starting on this. :\ I'm an idiot. Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/175883-sending-e-mails/#findComment-926727 Share on other sites More sharing options...
Alex Posted September 29, 2009 Share Posted September 29, 2009 Am I missing something? Because you posted this: $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } (!$validationOK) would never validate to true.. Because all you do is set $validationOK to true then do nothing else regarding that variable. I also just realized your $Email variable is already set to $_POST['Email']. Maybe it would be best if you post your form. Quote Link to comment https://forums.phpfreaks.com/topic/175883-sending-e-mails/#findComment-926729 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.