| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Feb 2006
Posts: 97
![]() | PHP Question Hey folks - I have a contact form setup at www.mydomain.com/contact.html . After someone enters there info, /mail.php processes it and they are then returned to my homepage. An issue I am having is that people (or bots) are going to /mail.php directly which causes me to have a blank contact form sent to me. Is there a way to restrict individuals from going directly to /mail.php or to prevent the blank contact forms from being sent to me? Any suggestions will be appreciated. Thanks! |
| |
| | #4 (permalink) | ||||
| NamePros Regular Join Date: Jul 2005 Location: Tucson, AZ
Posts: 689
![]() |
????: NamePros.com http://www.namepros.com/programming/332883-php-question.html But yea, post the code, all of the techniques mentioned are simple < 2 minute edits. | ||||
| |
| | #5 (permalink) |
| NamePros Member Join Date: Sep 2006
Posts: 78
![]() | Alternatively you could use an image verification such as Captcha. This will typically prevent bots from bypassing the form without entering the correct code. It need not be anything complex as the only sites that have to worry about their complexity would be such sites like Gmail, who would be a prime target for people trying to decipher their verification image. |
| |
| | #6 (permalink) |
| Senior Member Join Date: Aug 2005 Location: East Yorkshire, England
Posts: 2,689
![]() ![]() ![]() ![]() ![]() ![]() ![]() | You could just use this: PHP Code: |
| |
| | THREAD STARTER #7 (permalink) |
| NamePros Member Join Date: Feb 2006
Posts: 97
![]() | Mikor or anybody else...if you could mod this and make the code that you add in bold so I can see it, that would be appreciated. <? ????: NamePros.com http://www.namepros.com/showthread.php?t=332883 $company_name = $_REQUEST['company_name'] ; $first_name = $_REQUEST['first_name'] ; $last_name = $_REQUEST['last_name'] ; $title = $_REQUEST['title'] ; $address = $_REQUEST['address'] ; $city = $_REQUEST['city'] ; $state = $_REQUEST['state'] ; $zip = $_REQUEST['zip'] ; $phone = $_REQUEST['phone'] ; $email = $_REQUEST['email'] ; $hearaboutus = $_REQUEST['hearaboutus'] ; $number_of_employee = $_REQUEST['number_of_employee'] ; $industry = $_REQUEST['industry'] ; $description = $_REQUEST['description'] ; mail("NAME@NAME.com","Contact Request"," Contact name: $company_name\n First Name: $first_name\n Last Name: $last_name\n Title: $title\n Address: $address\n City: $city\n State: $state\n Zip: $zip\n Country: $country\n Phone: $phone\n Email: $email\n Hear about us: $hearaboutus\n Number of Employees: $number_of_employee\n Industry: $industry\n Comments: $description"); ?> <script> <!-- window.location= "/home.html" //--> </script> <?php exit;?> |
| |
| | #8 (permalink) |
| Senior Member Join Date: Aug 2005 Location: East Yorkshire, England
Posts: 2,689
![]() ![]() ![]() ![]() ![]() ![]() ![]() | PHP Code: |
| |
| | THREAD STARTER #9 (permalink) |
| NamePros Member Join Date: Feb 2006
Posts: 97
![]() | Mikor - thanks for the post. The fields that we require in the HTML contact form are: company_name first_name last_name address city state phone Is there a way that the php form that you posted could be modded for this? |
| |
| | #10 (permalink) |
| Senior Member Join Date: Aug 2005 Location: East Yorkshire, England
Posts: 2,689
![]() ![]() ![]() ![]() ![]() ![]() ![]() | Done PHP Code: |
| |
| | #11 (permalink) |
| Senior Member Join Date: Mar 2005
Posts: 4,948
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 1.) Do not use $_REQUEST, use the proper $_POST or $_GET 2.) Here's another way: PHP Code: |
| |