Link to home
Start Free TrialLog in
Avatar of kgerb
kgerbFlag for United States of America

asked on

PHP Contact Form Not Sending Email

Hello Everyone,
I'm trying to develop a website with a contact form.  I have received some help on this in the past from Ray (here) and Marco (here).  I think I Have everything set up correctly but I don't actually receive any email after clicking 'Submit'.  There is no error generated from the PHP mail function and the mail is not ending up in my Junk folder.  Nothing is happening at all.  I know this can be difficult to accomplish but I need to try.

I'm new to PHP and all things web development but I've been trying to learn as much as possible to try and figure this out.  Please let me know if I need to change something in the way I have this set up.  I think I may need send the Post array via an AJAX call in my JS instead of the way I'm doing it now.

All the files necessary to run my site via your local server are attached.  After loading the site from the index.php file click the Contact button in the Nav bar.  Fill out the form and click Submit.  Also, you'll probably want to change these two values for testing purposes.
User generated image
Also, when you click Submit, the form will disappear.  You have to click on Contact again in order to see the 'Success' message.  I'm sure I'll need to ask another question to fix this, but one thing at a time :-).

Thanks in advance,
Kyle
MySite.zip
Avatar of kgerb
kgerb
Flag of United States of America image

ASKER

I just received a test email to my outlook account from giuseppe so something is working :-).
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Marco Gasi
Yep, the mail from giuseppe was mine :-)
Your form works correctly: the email are sent with no exception. I can't reproduce the bug: the form remains visible. Don't remember if I've asked for this yet, but can you give a live link? So I can play with it to try to understand what happens. In my tests everything works as expected.
Avatar of kgerb

ASKER

Marco,
I uploaded my new index.php file to the live server.  I just sent myself an email and it worked.  Can you please test it for me one more time.

Here's a link

At least it's something until I can get a more robust solution put together.  

Kyle
Avatar of kgerb

ASKER

Ray,
My plan is to move away from sending myself an email when the Submit button is clicked.  Instead I plan to log the data like you said.  What's your suggestion as to the best way to do this.  My first thought was to create a text file containing the form information each time someone submits something.  So essentially I would end up with a directory full of text files.  Then I thought I could also create an Access database and dump the data in there using ADO (I guess it would be ADO).  What is your suggestion?

Kyle
Done. Yes I see the form which goes away. Let me play a bit...
Avatar of kgerb

ASKER

Marco,
I just received 3 test messages from you.  The first was at 5:45pm and the last was at 5:49pm.  Is that how many you sent?

Kyle
3 emails yes.
About logging, if you want to use a text file just use file_put_contents() this way:

file_put_contents( 'LogFile.txt', $logString . "\n", FILE_APPEND );

Open in new window


But I usually log to a database table: it is just easier using standard db routines.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kgerb

ASKER

Ray,
Thanks for the input and the article.  Excellent work.  I'm going to start working on logging the form info to a database.

Marco,
Thanks for the input as well.  I figured Submit was causing the page to reload.  

Thanks again to both of you.
Kyle