Reply Thread Tools Search this Thread
Old 17-06-2010, 19:27   #1 (permalink)
london31
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
  Reply With Quote
Old 17-06-2010, 19:47   #2 (permalink)
london31
Registered User
 
Join Date: Jun 2009
Posts: 15
Oh and I forgot to mention our company doesn't have the program FrontPage on any of the computers so all changes to the form itself would have to be done to the source code.

Thanks again for any help.
  Reply With Quote
Old 17-06-2010, 19:51   #3 (permalink)
7twelve
42nd amendment
 
7twelve's Avatar
 
Join Date: Aug 2008
Posts: 872
html looks fine (if horrible practice)

post up the code for the php script that processes the form
  Reply With Quote
Old 17-06-2010, 20:13   #4 (permalink)
london31
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 ;

?>
  Reply With Quote
Old 17-06-2010, 20:20   #5 (permalink)
london31
Registered User
 
Join Date: Jun 2009
Posts: 15
This is all on a server that has PHP 5 installed on it.
  Reply With Quote
Old 17-06-2010, 20:30   #6 (permalink)
7twelve
42nd amendment
 
7twelve's Avatar
 
Join Date: Aug 2008
Posts: 872
looks like this may be the culprit

Code:
if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ;

change to the proper capitalization. or use your variable you've already set up earlier
  Reply With Quote
Old 17-06-2010, 20:32   #7 (permalink)
Derek Smalls
Eat shit!
 
Derek Smalls's Avatar
 
Join Date: Feb 2010
Posts: 2,263
Yup...or
PHP Code:
if (!isset($_POST['Email'])) {
header"Location: $formurl);
exit ; 
__________________
I like to play
  Reply With Quote
Old 17-06-2010, 20:34   #8 (permalink)
7twelve
42nd amendment
 
7twelve's Avatar
 
Join Date: Aug 2008
Posts: 872
edited post for clarity on options. Personally I'd use the variable as you've already set it up
  Reply With Quote
Old 17-06-2010, 20:49   #9 (permalink)
london31
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.
  Reply With Quote
Old 17-06-2010, 21:00   #10 (permalink)
7twelve
42nd amendment
 
7twelve's Avatar
 
Join Date: Aug 2008
Posts: 872
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
  Reply With Quote
Old 17-06-2010, 23:02   #11 (permalink)
london31
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.
  Reply With Quote
Old 17-06-2010, 23:20   #12 (permalink)
Agricola
Senior Member
 
Agricola's Avatar
 
Join Date: May 2007
Location: England
Posts: 1,136
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:
<label id="human"><input type="text" name="location" value="" />Leave this blank</label>

if(
$_POST['location'] == ""){
Lets process the form!!!

}else{
Ignore its a robot!

__________________
War is Gods way of teaching Americans Geography
Wot Speeling Mishtake?
  Reply With Quote
Old 18-06-2010, 01:33   #13 (permalink)
Shiro
社長
 
Shiro's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 14,513
I used to use the hidden form field method, but then the bots started getting through a couple of my forms. Now I use a captcha.
__________________
This space for rent.

Jaypan | Ramenities
  Reply With Quote
Old 18-06-2010, 09:01   #14 (permalink)
Agricola
Senior Member
 
Agricola's Avatar
 
Join Date: May 2007
Location: England
Posts: 1,136
Quote:
Originally Posted by Shiro
I used to use the hidden form field method, but then the bots started getting through a couple of my forms. Now I use a captcha.

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?
  Reply With Quote
Old 18-06-2010, 18:31   #15 (permalink)
london31
Registered User
 
Join Date: Jun 2009
Posts: 15
Which captcha are you currently using?
  Reply With Quote
Old 18-06-2010, 18:51   #16 (permalink)
Agricola
Senior Member
 
Agricola's Avatar
 
Join Date: May 2007
Location: England
Posts: 1,136
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?
  Reply With Quote
Old 18-06-2010, 19:56   #17 (permalink)
Derek Smalls
Eat shit!
 
Derek Smalls's Avatar
 
Join Date: Feb 2010
Posts: 2,263
I always find that a simple sum e.g. 1+2= ____ works fine
__________________
I like to play
  Reply With Quote
Old 18-06-2010, 22:22   #18 (permalink)
7twelve
42nd amendment
 
7twelve's Avatar
 
Join Date: Aug 2008
Posts: 872
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.
  Reply With Quote
Old 18-06-2010, 23:27   #19 (permalink)
london31
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 ;

?>
  Reply With Quote
Old 19-06-2010, 00:20   #20 (permalink)
Derek Smalls
Eat shit!
 
Derek Smalls's Avatar
 
Join Date: Feb 2010
Posts: 2,263
@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,
__________________
I like to play
  Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive
vBulletin © 2000-2009 Jelsoft Enterprises Limited.
Search Engine Optimization by vBSEO 3.0.0 RC8