A PHP question...
lershee
Keeper of JSterling Heights, MI Icrontian
Hey guys and gals - I'm having an issue with a PHP form and I knew exactly where I should go. :-)
I'm working on a website for a friend of mine, and she wanted a form on her site (i.e. Name, Email, Phone number, etc.) That was easy to do in HTML, but then to submit it via email you had to know a PHP script. So, I researched online and actually learned how to do the code with a YouTube video. Everything seems to work, but when I fill this out and send it to my address (just to test it out), it sends it, but in my email there's nothing on the message. No name, no email, no nada. I watched the video again and it *seems* that I did everything right. So, someone tell me: WHAT DID I SCREW UP?!?
Thanks in advance. :-)
I'm working on a website for a friend of mine, and she wanted a form on her site (i.e. Name, Email, Phone number, etc.) That was easy to do in HTML, but then to submit it via email you had to know a PHP script. So, I researched online and actually learned how to do the code with a YouTube video. Everything seems to work, but when I fill this out and send it to my address (just to test it out), it sends it, but in my email there's nothing on the message. No name, no email, no nada. I watched the video again and it *seems* that I did everything right. So, someone tell me: WHAT DID I SCREW UP?!?
Thanks in advance. :-)
0
Comments
mail("$mailto","$subject","$message","$headers");
Please make sure to include your headers when you paste the code, that could be the issue.
If you aren't sure, what Lincoln is saying is instead of:
Name: $name
you should have
Name: $nameField
and so on.
$success = mail($webMaster, $emailSubject, $body, $headers);
This is the function that actually sends your mail, so it is formatted properly and you send your message out with $body. So my earlier question is answered yes.
To be clear, with your first attempt and initial code .. with the email you did receive ...
Did you see Name: __________ , Email: ____________
or was the body of the email literally 100% blank?
When posting your code, paste it, then highlight it all and click the "C" button in the reply window. It is between the S and the little picture Icon.
You should end up with
at the end.at the beginning and
$_POST['firstname'];
requires that your original HTML look something like this:
So I would revert to your original PHP that you posted, which at least sent the email. Then double check your HTML to make sure your variables (or form data) are matching with your POST variables in PHP.
====
Control-C just copies text in Windows, you need to press the button @BobbyDigi is referring to if you want to properly post code in the forum.
HTML PHP
===================
If you see the message in your browser after submitting the form, that means there were no problems in the Mail() function. So check your spam folders, or any gmail filters you have to make sure it is not hiding somewhere.
If you see "Sorry, something didn't work" you should contact your web host and ask them to enable php error reporting / logging so you can get a more helpful error message and we can find out what went wrong.