Contact Form/PHP Script help needed!

by 22 replies
25
I posted in the Website Design section earlier, but I think this is area is more relevant. I'm having some issues with contact forms on my website, and I'd really appreciate your input on this!

I have identical contact forms on 2 pages of a website, and both use the same contact.php script to send contact emails to my designated email address.

One of the forms is working, and the other one does not send out contact emails even though both are essentially identical and call the same php script.

I have changed the form ID on the second contact form (the one which isn't working), but it still isn't functioning like it should. What else should I change on the second form in order to make it work?

Thanks,
Paul
#programming #contact #form or php #needed #script
  • I'd appreciate it if any of the developers in here could help me with this contact form issue, I'd really like to get this resolved today.
    • [1] reply
    • Do you have Firefox?

      Try installing Live HTTP Headers

      That will allow you to see exactly what the forms are posting, and compare them.

      Cheers,
      Phil
  • Thanks Phil, but off-hand, do you know how you'd configure two identical forms on two separate pages on your website so that both would submit the same form data?
    • [1] reply
    • Can you post a link here to the forms?
  • Yup, without looking at some kind of code, we won't really be able to help.

    You say they are "essentially" the same... But what exactly is different?
    • [1] reply
    • They are identical, just on two different pages - same fields, everything is the same.
  • Ok, here goes, form 1 is on the index page here - http://sneakycpasecrets.com/

    Form 2 (identical fields) is on the Contacts page here - http://sneakycpasecrets.com/index-5.html

    I have tried defining the forms with different names and even attempted calling a different contact.php file (contact1.php), but all that doesn't seem to have worked.
    • [1] reply
    • Is the script checking the referring page by any chance?
  • No, the script is not checking the referring page, there are no references to the referring pages at all in the script.
  • I can post the contact.php script here, if you'd like to take a look at it.
    • [1] reply
    • Sure. PM it if you like, or post it here if you want more eyeballs.
  • Here's the basic script, I have been playing around with the parameters on it but to no avail -

    <?
    $subject="lawyer contact: from ".$_GET['your-name1'];
    $headers= "From: ".$_GET['your-email1']."\n";
    $headers.='Content-type: text/html; charset=iso-8859-1';
    mail("emailaddress@gmail.com", $subject, "
    <html>
    <head>
    <title>Contact letter</title>
    </head>
    <body>
    State:
    ".$_GET['your-state1']."
    <br>
    <br>
    Message:
    ".$_GET['your-message1']."
    </body>
    </html>" , $headers);
    echo ("Your message was successfully sent! Thank you.");
    ?>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    window.location.href = "http://www.sneakycpasecrets.com/index.html";
    //-->
    </script>
    • [1] reply
    • As it stands that won't work with either form.

      Just remove the trailing '1' from the GET variables and you should be good to go.

      Probably best to redact your email address from the post too.

      Cheers,
      Phil

      P.S. Do you get much spam from that form? Might want to think about a CAPTCHA or something...
  • Phil, thanks for the advice regarding the spam issue. I have tried renaming the variables and added the 1 to the end of the original ones, but either way that second form isn't working. How would you configure my current set up, and what would you change on the second contact form (the one on my Contacts page is working, but the one on the index page isn't working)?

    Thanks again,
    Paul
  • Phil, I basically tried to rename the variables and the form on the index page (and even made the form call a contact1.php script instead of the original contact.php) just to see if it would change things. Originally I tried to keep everything exactly the same on the index page as it was on the first form (on the Contacts page), but that definitely didn't work.
  • Quick update - it seems to be working now! I'm not sure what happened as I did NOT FTP anything new to my server over the last 12 hours or so. This is really strange, I did this last night (morning actually) when I was half asleep - I think I really should lay off the programming at 4 am...lol!
  • Just out of curiosity, is there any way that we can do this with just 1 php script? The way I've set it up right now is a little messy - I have two php scripts, one for each identical contact form which is on a separate page on my website. I have also renamed the variables that it passes to the php script, as well as the form IDs. Is there a easier, more organized way of doing this?

    Thanks,
    Paul
    • [1] reply
    • Don't forget to always use strip_tags when filtering data from forms to avoid malicious data.
  • @wattzy - thanks for reminding me about using strip_tags, sometimes when there are ten thousand things to do with a website it's easy to overlook things like this.
    • [1] reply
    • What capcha are you using for your contact form? Is it safe to use from spamming?
  • Haven't implemented Captcha yet, I've been a little lazy about that - any good scripts you'd like to recommend?
  • hey try this.

    rename the file from index5.html to index5.php

    as you have used get functions this may surely solve your problem.
    check it and let me know.


    regards
    anuradhan
  • Banned
    [DELETED]
  • Banned
    [DELETED]

Next Topics on Trending Feed

  • 25

    I posted in the Website Design section earlier, but I think this is area is more relevant. I'm having some issues with contact forms on my website, and I'd really appreciate your input on this! I have identical contact forms on 2 pages of a website, and both use the same contact.php script to send contact emails to my designated email address.