PHP to send message from a form

grayandpartners.com

^This website is broken on the bottom, which is the contact form. I have no idea what I did to screw it up so badly, but nothing I’m trying for PHP is working. Any ideas? I’ve researched sending forms from PHP n’ stuff but nothing works. Help please, I’m fed up with this issue.

You’ll have to be more specific. There’s no way that anyone can help you if you don’t tell us what goes behind.

Yes, the only information the page provides is that the form sends to
send_form_email.php

Please post the code for that here (with any sensitive content *******'d out)

I’ve tried using this code which I found online:

Other than that, I have no idea what I’m doing.

The HTML and the PHP won’t work as it is now

The form sends 3 POST fields
* one missing a “>” which causes several errors to be reported because of that one mistake
https://validator.w3.org/nu/?doc=http%3A%2F%2Fgrayandpartners.com%2F

<input  name="name"  id="name"  placeholder="Name" type="text"> 
<input  name="email"  id="email"  placeholder="Email" type="text" 
<textarea  name="message"  id="message" placeholder="Message" rows="4"></textarea> 

But the PHP script is testing for 5 form fields

    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['last_name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['telephone']) ||
        !isset($_POST['comments'])) {

The “names” of the form inputs need to be the same as the names in the $_POST array.

So you can either add those to the form, or remove them from the PHP file.

OK, cool. I fixed that error.

So for the PHP file, if I just rename all the ‘first_name’ to ‘name’, leave the email alone, and change the ‘comments’ to message, it should work, right? (I’m probably testing this right now, I’ll report back with my findings.)

Alright, it still doesn’t work. (Moved the website I’m testing to:
http://gmrgames.com/dev )

So here’s the form so far:
http://pastebin.com/xVidqPiF

And of course I fixed the error you highlighted above. Still doesn’t work with my renaming/removing stuff. Any idea what I’m doing wrong?

Other than a deprecated <center> tag which shouldn’t be more than a display problem for some browsers, the PHP file and form HTML look OK to me.

When you say “doesn’t work” what exactly do you mean?

Error messages?
Blank page?
No apparent errors but not getting the email?
etc.

1 Like

Well, I fill out the form as a test and hit send message. The URL changes at the top, but nothing happens. If it worked successfully, shouldn’t I be getting an email? In the php, it’s also supposed to say something like ‘Thank you response received or something.’

Thanks.

It seems that as long as the PHP file is named
send_form_email.php (case matters)
and is in the “dev” folder you should be seeing

Thank you for contacting us. We will be in touch with you very soon.

if the PHP sends it off to the mail server.

Whether or not the email server is sending it to your email, and whether or not your email client is rejecting it or sending it to your Trash box is another story.

My other contact form works fine for this though. (gmrgames.com/contact)

It doesn’t give a confirmation message. I click the button and nothing happens. :frowning:

Simple process to email PHP contact form - http://www.freecontactform.com/email_form.php

Thanks, but no. If you’d read the thread, that’s what we’re trying to work with.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.