| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| DesignersTalk > Converting a Frontpage form to a PHP form in htm file. |
|
Thread Tools | Search this Thread |
|
|
#1 (permalink) |
|
Registered User
Join Date: Jun 2009
Posts: 15
|
Converting a Frontpage form to a PHP form in htm file.
I'm in a bit of a pickle. Recently my company was given a website to redesign that was created in FrontPage 4.0. In addition to redesigning this website we are going to be hosting it as well. During the redesign process the client would like to get their current frontpage designed website migrated over to our server and have their forms that were created in FrontPage to work properly. I don't really know anything about frontpage, but the forms aren't working when they are migrated over to our server. I have a little bit of experience with PHP (not much though) so I was looking at changing the FP form to a PHP form. Once I changed the code though and a user clicks submit it doesn't call the php action in the form. Does anyone have any thoughts on how I can effectively change the frontpage form code to call a php script and get the forms to work? Here is the url of the page that I'm trying to make function properly artmil. com/bfoa/PtApptRegFormTemp.htm Here is the url of the original FrontPage Code artmil. com/bfoa/PtApptRegFormTemp2.htm Any help would be greatly appreciated. Thank you in advance. Jeff |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: Jun 2009
Posts: 15
|
Yeah I wasn't going to waste the time to tackle that HTML code. Technically my company shouldn't have to be revising these forms as it wasn't discussed in the original quote and these forms won't be utilized in 3-4 weeks anyway when the new site goes live, so I'm trying to do this as painlessly and quickly as possible. Below is the ptformsubmit.php file script. I've x'd out the email addresses. I'm still learning PHP so let me know if there is anything that I can do to clean up the script as well. I've had to adjust the form url, error url and thankyouurl as I don't have the necessary number of posts on here to be able to post url's. Thank you for taking the time to look this over. <?php // ------------- CONFIGURABLE SECTION ------------------------ $mailto = "xxxx@xxxxxxx.xxx" ; $secondmailto = "xxxx@xxxxxxx.xxx" ; $formurl = "artmil. com/bfoa/PtApptRegFormTemp.htm" ; $errorurl = "artmil. com/bfoa/ptapptformerror.htm" ; $thankyouurl = "artmil. com/bfoa/formsubmitted.htm" ; $uself = 1; // -------------------- END OF CONFIGURABLE SECTION --------------- // -------------------- POST DATA INFORMATION --------------- $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; $newpatient = $_POST['NewPatient'] ; $existingpatient = $_POST['ExistingPatient'] ; $name = $_POST['Name'] ; $address = $_POST['Address'] ; $state = $_POST['State'] ; $zip = $_POST['Zip'] ; $email = $_POST['Email'] ; $insurance = $_POST['HealthInsurance'] ; $physician = $_POST['PhysicianPreference'] ; $monday = $_POST['Monday']; $mondayhours = $_POST['MondayHours']; $tuesday = $_POST['Tuesday'] ; $tuesdayhours = $_POST['TuesdayHours']; $wednesday = $_POST['Wednesday']; $wednesdayhours = $_POST['WednesdayHours']; $thursday = $_POST['Thursday']; $thursdayhours = $_POST['ThursdayHours']; $friday = $_POST['Friday'] ; $fridayhours = $_POST['FridayHours']; $location = $_POST['Location']; $phone = $_POST['ContactTelephone'] ; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ; } //------------------ THIS IS THE REQUIRED FIELDS -------------- if (empty($name) || empty($address) || empty($address) || empty($state) || empty($zip) || empty($email) || empty($insurance) || empty($physician) || empty($location) || empty($phone)) { header( "Location: $errorurl" ); exit ; } if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $address ) || ereg( "[\r\n]", $state ) || ereg( "[\r\n]", $zip ) || ereg( "[\r\n]", $email ) || ereg( "[\r\n]", $phone ) ) { header( "Location: $errorurl" ); exit ; } if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } // Subject Line (if you want a $_POST data to display the users voucher #) $subject = "Patient Appointment Registration Form Submission" ; $messageproper = "Patient Appointment Registration Form \n". "\n" . "This message was sent from:\n" . "$http_referrer\n" . "------------------------------------------------------------\n" . "New Patient: $newpatient\n" . "Existing Patient: $lastname\n" . "Name: $name\n" . "Address: $address\n" . "State: $state\n" . "Zip: $zip\n" . "Email: $email\n" . "Health Insurance: $insurance\n" . "Physician Preference: $physician\n" . "Monday: $monday\n" . "Monday Hours: $mondayhours\n" . "Tuesday: $tuesday\n" . "Tuesday Hours: $tuesdayhours\n" . "Wednesday: $wednesday\n" . "Wednesday Hours: $wednesdayhours\n" . "Thursday: $thursday\n" . "Thursday Hours: $thursdayhours\n" . "Friday: $friday\n" . "Friday Hours: $fridayhours\n" . "Location: $location\n". "Telephone Number: $phone\n" . "\n\n------------------------------------------------------------\n" ; mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.08" ); mail($secondmailto, $subject, $messageproper, "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.08" ); header( "Location: $thankyouurl" ); exit ; ?> |
|
|
|
#9 (permalink) |
|
Registered User
Join Date: Jun 2009
Posts: 15
|
Thanks guys, that did the trick. You're awesome. I'm looking at adding a captcha to this form, do either of you know of a good resource for incorporating one of these? I can google it, but I didn't know if you knew of a good website for a beginner that would walk me through the steps to implement this. |
|
|
|
#10 (permalink) |
|
42nd amendment
Join Date: Aug 2008
Posts: 876
|
Personally I hate captchas with a passion, and I'd never use a contact form with one. The method I like to do is set up a text field and hide it via CSS while giving it an important sounding name, then I check to make sure that it is empty (most bots will auto fill every field) before processing |
|
|
|
#11 (permalink) |
|
Registered User
Join Date: Jun 2009
Posts: 15
|
7twelve- Since I'm still new to PHP could you help me out to verifty that it is empty in the PHP? I know it's probably something real simple, but I want to make sure that I get it right. Below is the invisible field implemented into the html form area <input id="human" type="text"> I currently have the css in the header of the same page, #human { visibility:hidden; display:none; } Thank you again for any help you may be able to offer. |
|
|
|
#12 (permalink) |
|
Senior Member
Join Date: May 2007
Location: England
Posts: 1,143
|
From accessibility point of view its not a brilliant idea to have a hidden field like this, however it is a good solution to trap robots and one I also use , so if you are going down this road, then at least give the input box some text to tell user to leave it blank, if they have disabled style sheets or using text reader technology and can actually see it. It would also not hurt to give it a null value to start with. Theres several ways to check if this value contains data, I have used a basic but fool proof method in example below. PHP Code:
War is Gods way of teaching Americans Geography
Wot Speeling Mishtake? |
|
|
|
#14 (permalink) | |
|
Senior Member
Join Date: May 2007
Location: England
Posts: 1,143
|
Quote:
bugger should have known it was only a matter of time before they evolved to bypass this. War is Gods way of teaching Americans Geography
Wot Speeling Mishtake? |
|
|
|
|
#16 (permalink) |
|
Senior Member
Join Date: May 2007
Location: England
Posts: 1,143
|
I will create my own, I would also like to think that Shiro is also using his own. Problem is many of the popular Captchas, especailly the ones that come with the open source installs of whatever, are being cracked by the robots. War is Gods way of teaching Americans Geography
Wot Speeling Mishtake? |
|
|
|
#18 (permalink) |
|
42nd amendment
Join Date: Aug 2008
Posts: 876
|
another thing you could do (just thinking out loud here, never tried this) is create a variable with the timestamp of when the page was loaded, pass that in the form and compare it to how long it took to complete the form. If a form like that took less than 30 seconds to fill out, you can be sure it's a bot But, sometimes on things like registration pages, etc where you offer a service and don't need much info, a captcha isn't a bad way to go. Just don't care for them in instances where the intent is to establish contact, especially when dealing with physician care (older people are bad enough with computers as it is, and you're covering a large demographic) I do prefer the simpler logic questions over nonsensical and ugly images tho. |
|
|
|
#19 (permalink) |
|
Registered User
Join Date: Jun 2009
Posts: 15
|
I understand 7twelve, by nature I'm a designer and not a programmer so pretty much all of this is new to me. I'll probably combine the invisible field with the php that Agricola mentions with a captcha as well if that's possible. I've started implementing the captcha, but I'm having issues combining the captcha check php code into the php that verifies the fields have been filled in and sends the email. The captcha check php code was free/donate captcha code that I found online. I keep getting a HTTP 500 Internal Server Error when I hit submit so I'm guessing that there is something wrong with the PHP code below. I'm guessing I need to put some code into the (2) ... lines, but I'm not sure what to put and if this is where the problem lies. Any help would be greatly appreciated. Thank you for all that you've done so far. Page: artmil. com/bfoa/PtApptRegFormTemp.htm PHP: <?php @session_start(); // start session if not started yet if ($_SESSION['AntiSpamImage'] != $_REQUEST['anti_spam_code']) { // set antispam string to something random, in order to avoid reusing it once again $_SESSION['AntiSpamImage'] = rand(1,9999999); // here you add code to let user know incorrect code entered ... } else { // set antispam string to something random, in order to avoid reusing it once again $_SESSION['AntiSpamImage'] = rand(1,9999999); // everything is fine, proceed with processing feedback/comment/etc. ... } // ------------- CONFIGURABLE SECTION ------------------------ // $mailto - set to the email address you want the form // sent to, eg //$mailto = "youremailaddress@example.com" ; $mailto = "xxxx@xxxxxx.com" ; $secondmailto = "xxxx@xxxxxx.com" ; $formurl = "artmil. com/bfoa/PtApptRegFormTemp.htm" ; $errorurl = "artmil. com/bfoa/ptapptformerror.htm" ; $thankyouurl = "artmil. com/bfoa/formsubmitted.htm" ; $uself = 1; // -------------------- END OF CONFIGURABLE SECTION --------------- // -------------------- POST DATA INFORMATION --------------- $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; $newpatient = $_POST['NewPatient'] ; $existingpatient = $_POST['ExistingPatient'] ; $name = $_POST['Name'] ; $address = $_POST['Address'] ; $state = $_POST['State'] ; $zip = $_POST['Zip'] ; $email = $_POST['Email'] ; $insurance = $_POST['HealthInsurance'] ; $physician = $_POST['PhysicianPreference'] ; $monday = $_POST['Monday']; $mondayhours = $_POST['MondayHours']; $tuesday = $_POST['Tuesday'] ; $tuesdayhours = $_POST['TuesdayHours']; $wednesday = $_POST['Wednesday']; $wednesdayhours = $_POST['WednesdayHours']; $thursday = $_POST['Thursday']; $thursdayhours = $_POST['ThursdayHours']; $friday = $_POST['Friday'] ; $fridayhours = $_POST['FridayHours']; $location = $_POST['Location']; $phone = $_POST['ContactTelephone'] ; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['Email'])) { header( "Location: $formurl" ); exit ; } //------------------ THIS IS THE REQUIRED FIELDS -------------- if (empty($name) || empty($address) || empty($address) || empty($state) || empty($zip) || empty($email) || empty($insurance) || empty($physician) || empty($location) || empty($phone)) { header( "Location: $errorurl" ); exit ; } if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $address ) || ereg( "[\r\n]", $state ) || ereg( "[\r\n]", $zip ) || ereg( "[\r\n]", $email ) || ereg( "[\r\n]", $phone ) ) { header( "Location: $errorurl" ); exit ; } if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } // Subject Line (if you want a $_POST data to display the users voucher #) $subject = "Patient Appointment Registration Form Submission" ; $messageproper = "Patient Appointment Registration Form \n". "\n" . "This message was sent from:\n" . "$http_referrer\n" . "------------------------------------------------------------\n" . "New Patient: $newpatient\n" . "Existing Patient: $lastname\n" . "Name: $name\n" . "Address: $address\n" . "State: $state\n" . "Zip: $zip\n" . "Email: $email\n" . "Health Insurance: $insurance\n" . "Physician Preference: $physician\n" . "Monday: $monday\n" . "Monday Hours: $mondayhours\n" . "Tuesday: $tuesday\n" . "Tuesday Hours: $tuesdayhours\n" . "Wednesday: $wednesday\n" . "Wednesday Hours: $wednesdayhours\n" . "Thursday: $thursday\n" . "Thursday Hours: $thursdayhours\n" . "Friday: $friday\n" . "Friday Hours: $fridayhours\n" . "Location: $location\n". "Telephone Number: $phone\n" . "\n\n------------------------------------------------------------\n" ; mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.08" ); mail($secondmailto, $subject, $messageproper, "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.08" ); header( "Location: $thankyouurl" ); exit ; ?> |
|
|
|
#20 (permalink) |
|
Eat shit!
Join Date: Feb 2010
Posts: 2,003
|
@7twelve: that seemed like a good idea for a bit with the timestamp thing, but you'd have to consider the people that use an autofill tool on their browser. I can fill my name, address, emails and phone numbers in less than a couple of seconds, |
|
![]() |
|