Link to home
Start Free TrialLog in
Avatar of rodneygray
rodneygrayFlag for United States of America

asked on

File name as variable PHP

I have an existing form that I am modifying for another use. I want to be able to name the file to lastname.firstname.txt,  eg: Lewis.Charles.txt.

My question is the code below correct for doing that.
I am rusty on my quote usage for PHP.

$filename = "apps/'$lname'.'$fname'.txt"; //File to be written to

Open in new window

SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dave Baldwin
And file names with spaces in them are often a problem.  You also need to filter out special characters in that operating system like '\', '/', and others.  Because someone will try to use them.  Like "John/Becky Morgan".
Avatar of rodneygray

ASKER

Below is the complete code.

<?php 

/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||| Variables ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

$today = date("DATE_RFC2822"); // sets $today to today's date from client device

	$fname = $_POST['fname'];
	$lname = $_POST['lname'];
	$phone = $_POST['phone'];
	$addr = $_POST['addr'];
	$city = $_POST['city'];
	$state = $_POST['state'];
	$zip = $_POST['zip'];
	$email = $_POST['email'];
	$besttime = $_POST['besttime'];
	$contactmethod = $_POST['contactmethod'];
	$dob = $_POST['dob'];
	$howhear = $_POST['howhear'];
	if(isset($_POST['cardiosurgery']))  { $cardiosurgery = "YES"; }
	if(isset($_POST['schdocvisits']))  { $schdocvisits = "YES"; }
	if(isset($_POST['homecare']))  { $homecare = "YES"; }
	if(isset($_POST['ekgtesting']))  { $ekgtesting = "YES"; } 
	if(isset($_POST['other']))  { $other = "YES"; }
	$othermsg = $_POST['othermsg'];

/* ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||| Validation ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

 switch (@$_GET['do'])

  {

    case "send":
      if (!preg_match("/\S+/",$fname))
      {
        unset($_GET['do']);
        $message = "First Name required. Please try again.";
         break;
      }
      if (!preg_match("/\S+/",$lname))
      {
        unset($_GET['do']);
        $message = "Last Name required. Please try again.";
         break;
      }
      if (!preg_match("/^\S+@[A-Za-z0-9_.-]+\.[A-Za-z]{2,6}$/",$email))
      {
        unset($_GET['do']);
        $message = "Proper Email Address format: example@website.net Please try again.";
        break;
      }
      if (!preg_match("/^[0-9 #\-\*\.\(\)]+$/",$phone))
      {
        unset($_GET['do']);
        $message = "Phone Number required. No letters, please.";
         break;
      }

/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||| Set message to null if no error ||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

       $message = '';
       unset($_GET['do']);
     break;
 default: break;
   }

/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||| Write Variables to File ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/


	if(isset($_POST['submit'])){

	if ($message == "") {

	$filename = "files/$lname.$fname.txt";

	$fhandle = fopen($filename, 'w'); // variable to hold file name

	fwrite($fhandle,'Date: '.$today."\n"); //Writes $today to textfile

	fwrite($fhandle,'Best Time to Call: '.$besttime."\n"); //Writes $besttime to textfile

	fwrite($fhandle,'ContactMethod: '.$contactmethod."\n"); //Writes $contactmethod to textfile

	fwrite($fhandle,'First Name: '.$fname."\n"); //Writes $today to textfile

	fwrite($fhandle,'Last Name:~ '.$lname."\n"); //Writes $today to textfile

	fwrite($fhandle,'Phone Number: '.$phone."\n"); //Writes $today to textfile

	fwrite($fhandle,'Address: '.$addr."\n"); //Writes $today to textfile

	fwrite($fhandle,'City: '.$city."\n"); //Writes $today to textfile

	fwrite($fhandle,'State: '.$state."\n"); //Writes $today to textfile

	fwrite($fhandle,'Zip: '.$zip."\n"); //Writes $today to textfile

	fwrite($fhandle,'Email: '.$email."\n"); //Writes $today to textfile

	fwrite($fhandle,'Date of Birth: '.$dob."\n"); //Writes $today to textfile

	fwrite($fhandle,'Cardiovascular Surgery: '.$nursesvc."\n"); //Writes $today to textfile

	fwrite($fhandle,'Schedule Dr. Visits: '.$pcare."\n"); //Writes $today to textfile

	fwrite($fhandle,'Home Care: '.$homecare."\n"); //Writes $today to textfile

	fwrite($fhandle,'EKG Testing: '.$ekgtesting."\n"); //Writes $today to textfile

	fwrite($fhandle,'Other_Message~ '.$othermsg."\n"); //Writes $today to textfile

	fwrite($fhandle,'How did you hear about us: '.$howhear."\n"); //Writes $today to textfile

	fclose($fhandle);


/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||| phpmailer sends file as attachment |||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/



	require_once('class.phpmailer.php'); //File must be located in same directory
	
	$mail             = new PHPMailer(); // defaults to using php "mail()"
	$body             = file_get_contents('contents.html'); // File with message for email
	$body             = eregi_replace("[\]",'',$body);
	$mail->SetFrom('questioner@douglasmedical.com', 'Questioner Answers'); // Sent from Email Address/Name
	$mail->AddReplyTo("questioner@douglasmedical.com","Questioner Answers"); // Reply to email address
	$address = "questioner@douglasmedical.com"; // Email of Recipient
	$mail->AddAddress($address, "Questioner Answers"); // Name of Recipient
	$mail->Subject    = "DMS Patient Questioner from: For $plname, $pfname"; // Subject Line of Email
	$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
	$mail->MsgHTML($body);
	$mail->AddAttachment("apps/referral.txt");      // attachment

	if(!$mail->Send()) {

	  echo "Mailer Error: " . $mail->ErrorInfo;

	} else {

	  echo '<META HTTP-EQUIV="refresh" content="0;URL=thank_you.htm">'; // Redirect to thank you page

	}	}	}

?>

<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||| Start HTML CODE ||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Douglas Medical Specialists | Questioner Form</title>

<link rel="stylesheet" href="questioner.css" type="text/css" >
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<!-- JS to limit number of characters in text fields -->
<script language="javascript" type="text/javascript">
function limitText(limitField, limitCount, limitNum) {

	if (limitField.value.length > limitNum) {

		limitField.value = limitField.value.substring(0, limitNum);

	} else {

		limitCount.value = limitNum - limitField.value.length;

	}

}

</script>
<script type="text/javascript">
/***********************************************
* Disable "Enter" key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      
</script>
</head>
<body>
<center>
<form action="index.php?do=send" method="POST">
<p><a href="index.html">
<img alt="" src="images/doctors.png"></a></p>
	<h1>Patient Referrals</h1>
<p>Please fill in the Referral Form Below.</p>
<p><font color="red">*</font> Required Fields</p> <span style="color:red;">
<?php
	if ($message)
	echo "$message"; 
?>
</span>
   <table border="1" width="500">
	<TR bgcolor="#B2C6DE">
	<TD align="center" colSpan=6>Patient Information</TD>
	</TR>
   <tr><td width="150px">
   <font color="red">*</font> First Name: </td><td><input type="text" name="fname" size="20" value="<?php echo @$fname ?>"

   						onkeypress="return handleEnter(this, event);"

   						onKeyDown="limitText(this.form.fname,this.form.countdown9,45);" 

						onKeyUp="limitText(this.form.fname,this.form.countdown9,45);">

   </td></tr>
   <tr><td>
   <font color="red">*</font> Last Name: </td><td><input type="text" name="lname" size="20" value="<?php echo @$lname ?>"

   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.lname,this.form.countdown10,45);" 
						onKeyUp="limitText(this.form.lname,this.form.countdown10,45);">
   </td></tr>
   <tr><td>
   Phone Number: </td><td><input type="text" name="phone" size="20" value="<?php echo @$phone ?>"
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.phone,this.form.countdown11,12);" 
						onKeyUp="limitText(this.form.phone,this.form.countdown11,12);">
   </td></tr>
   <tr><td>
   Address: </td><td><input type="text" name="addr" size="20" value="<?php echo @$addr ?>"
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.addr,this.form.countdown12,80);" 
						onKeyUp="limitText(this.form.addr,this.form.countdown12,80);">
   </td></tr>
   <tr><td>
   City: </td><td><input type="text" name="city" size="20" value="<?php echo @$city ?>"
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.city,this.form.countdown13,20);" 
						onKeyUp="limitText(this.form.city,this.form.countdown13,20);">
   </td></tr>
   <tr><td>
   State: </td><td><input type="text" name="state" size="20" value="<?php echo @$state ?>"
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.state,this.form.countdown14,2);" 
						onKeyUp="limitText(this.form.state,this.form.countdown14,2);">
   </td></tr>
   <tr><td>
   Zip: </td><td><input type="text" name="zip" size="20" value="<?php echo @$zip ?>"
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.zip,this.form.countdown15,5);" 
						onKeyUp="limitText(this.form.zip,this.form.countdown15,5);">
   </td></tr>
   <tr><td>
   Email: </td><td><input type="text" name="email" size="20" value="<?php echo @$email ?>"
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.email,this.form.countdown16,50);" 
						onKeyUp="limitText(this.form.email,this.form.countdown16,50);">
   </td></tr>
   <tr><td>

   Date of Birth: </td><td><input type="text" name="dob" size="20" value="<?php echo @$dob ?>"

   						onkeypress="return handleEnter(this, event);"

   						onKeyDown="limitText(this.form.dob,this.form.countdown17,10);" 

						onKeyUp="limitText(this.form.dob,this.form.countdown17,10);">

   </td></tr>

   </table>



   <table border="1" width="500">

	<TR bgcolor="#B2C6DE">

	<TD align="center" colSpan=6>Questioner</TD>

	</TR>

   <tr><td>
	Are you interested in the following services?<br>
   <input type="checkbox" name="cardiosurgery" value="YES"> Cardiovascular Surgery<br>
   <input type="checkbox" name="schdocvisits" value="YES"> Scheduling Regular Doctor Visits<br>
   <input type="checkbox" name="homecare" value="YES"> Home Care (Housekeeping, Laundry, Meal Prep, etc.)<br>
   <input type="checkbox" name="ekgtesting" value="YES"> EKG Testing<br>
   <input type="checkbox" name="bloodwork" value="YES"> Blood Work<br>
   <input type="checkbox" name="other" > Other - Please Specify:<br>
   
   Other Information:<br>
   <textarea rows="5" cols="40" name="othermsg" 
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.othermsg,this.form.countdown18,240);" 
						onKeyUp="limitText(this.form.othermsg,this.form.countdown18,240);"
						><?php echo @$othermsg ?></textarea>

   </td></tr>
	<tr><td>How did you hear about Douglas Medical Specialists?<br>
	 <textarea rows="5" cols="40" name="howhear" 
	 					onkeypress="return handleEnter(this, event);"
	 					onKeyDown="limitText(this.form.howhear,this.form.countdown19,240);" 
						onKeyUp="limitText(this.form.howhear,this.form.countdown19,240);"
						><?php echo @$howhear ?></textarea></td></tr>
</table>
<br>
<input type="submit" name="submit" value="Click Here to Submit" style="height: 75px; width: 400px; font-size: 24px;">
   </form>
   </center>
</body>
</html>

<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||| End HTML CODE |||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -->

Open in new window

I've made several modifications trying to get it to work again but it seems like I broke something along the way.
<?php 
// Report all PHP errors
error_reporting(-1);
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||| Variables ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

$today = date("DATE_RFC2822"); // sets $today to today's date from client device

	$fname = $_POST['fname'];
	$lname = $_POST['lname'];
	$phone = $_POST['phone'];
	$addr = $_POST['addr'];
	$city = $_POST['city'];
	$state = $_POST['state'];
	$zip = $_POST['zip'];
	$email = $_POST['email'];
	$besttime = $_POST['besttime'];
	$contactmethod = $_POST['contactmethod'];
	$dob = $_POST['dob'];
	$howhear = $_POST['howhear'];
	if(isset($_POST['cardiosurgery']))  { $cardiosurgery = "YES"; }
	if(isset($_POST['schdocvisits']))  { $schdocvisits = "YES"; }
	if(isset($_POST['homecare']))  { $homecare = "YES"; }
	if(isset($_POST['ekgtesting']))  { $ekgtesting = "YES"; } 
	if(isset($_POST['other']))  { $other = "YES"; }
	$othermsg = $_POST['othermsg'];

/* ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||| Validation ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

 switch (@$_GET['do'])

  {

    case "send":
      if (!preg_match("/\S+/",$fname))
      {
        unset($_GET['do']);
        $message = "First Name required. Please try again.";
         break;
      }
      if (!preg_match("/\S+/",$lname))
      {
        unset($_GET['do']);
        $message = "Last Name required. Please try again.";
         break;
      }
      if (!preg_match("/^\S+@[A-Za-z0-9_.-]+\.[A-Za-z]{2,6}$/",$email))
      {
        unset($_GET['do']);
        $message = "Proper Email Address format: example@website.net Please try again.";
        break;
      }
      if (!preg_match("/^[0-9 #\-\*\.\(\)]+$/",$phone))
      {
        unset($_GET['do']);
        $message = "Phone Number required. No letters, please.";
         break;
      }

/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||| Set message to null if no error ||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

       $message = '';
       unset($_GET['do']);
     break;
 default: break;
   }

/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||| Write Variables to File ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/


	if(isset($_POST['submit'])){

	if ($message == "") {

	$filename = 'files/questions.txt'; //File to be written to

	$fhandle = fopen($filename, 'w'); // variable to hold file name

	fwrite($fhandle,'Date- '.$today."\n"); //Writes $today to textfile

	fwrite($fhandle,'Best Time to Call- '.$besttime."\n"); //Writes $besttime to textfile

	fwrite($fhandle,'ContactMethod- '.$contactmethod."\n"); //Writes $contactmethod to textfile

	fwrite($fhandle,'First Name- '.$fname."\n"); //Writes $today to textfile

	fwrite($fhandle,'Last Name- '.$lname."\n"); //Writes $today to textfile

	fwrite($fhandle,'Phone Number- '.$phone."\n"); //Writes $today to textfile

	fwrite($fhandle,'Address- '.$addr."\n"); //Writes $today to textfile

	fwrite($fhandle,'City- '.$city."\n"); //Writes $today to textfile

	fwrite($fhandle,'State- '.$state."\n"); //Writes $today to textfile

	fwrite($fhandle,'Zip- '.$zip."\n"); //Writes $today to textfile

	fwrite($fhandle,'Email- '.$email."\n"); //Writes $today to textfile

	fwrite($fhandle,'Date of Birth- '.$dob."\n"); //Writes $today to textfile

	fwrite($fhandle,'Cardiovascular Surgery- '.$nursesvc."\n"); //Writes $today to textfile

	fwrite($fhandle,'Schedule Dr. Visits- '.$pcare."\n"); //Writes $today to textfile

	fwrite($fhandle,'Home Care- '.$homecare."\n"); //Writes $today to textfile

	fwrite($fhandle,'EKG Testin- '.$ekgtesting."\n"); //Writes $today to textfile

	fwrite($fhandle,'Other_Message~ '.$othermsg."\n"); //Writes $today to textfile

	fwrite($fhandle,'How did you hear about us: '.$howhear."\n"); //Writes $today to textfile

	fclose($fhandle);


/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||| phpmailer sends file as attachment |||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/



	require_once('class.phpmailer.php'); //File must be located in same directory
	
	$mail             = new PHPMailer(); // defaults to using php "mail()"
	$body             = file_get_contents('contents.html'); // File with message for email
	$body             = eregi_replace("[\]",'',$body);
	$mail->SetFrom('office@graycomputer.net', 'Questioner Answers'); // Sent from Email Address/Name
	$mail->AddReplyTo("office@graycomputer.net","Questioner Answers"); // Reply to email address
	$address = "office@graycomputer.net"; // Email of Recipient
	$mail->AddAddress($address, "Questioner Answers"); // Name of Recipient
	$mail->Subject    = "DMS Patient Questioner from: For $plname, $pfname"; // Subject Line of Email
	$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
	$mail->MsgHTML($body);
	$mail->AddAttachment("files/questions.txt");      // attachment

	if(!$mail->Send()) {

	  echo "Mailer Error: " . $mail->ErrorInfo;

	} else {

	  echo '<META HTTP-EQUIV="refresh" content="0;URL=thank_you.htm">'; // Redirect to thank you page

	}	}	}

?>

<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||| Start HTML CODE ||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Douglas Medical Specialists | Questioner Form</title>

<link rel="stylesheet" href="questioner.css" type="text/css" >
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<!-- JS to limit number of characters in text fields -->
<script language="javascript" type="text/javascript">
function limitText(limitField, limitCount, limitNum) {

	if (limitField.value.length > limitNum) {

		limitField.value = limitField.value.substring(0, limitNum);

	} else {

		limitCount.value = limitNum - limitField.value.length;

	}

}

</script>
<script type="text/javascript">
/***********************************************
* Disable "Enter" key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      
</script>
</head>
<body>
<center>
<form action="index.php?do=send" method="POST">
<p><a href="index.html">
<img alt="" src="images/doctors.png"></a></p>
	<h1>Welcome to Douglas Medical Specialists!</h1>
<p>Please fill in the questioner below.</p>
<p><font color="red">*</font> Required Fields</p> <span style="color:red;">
<?php
	if ($message)
	echo "$message"; 
?>
</span>
   <table border="1" width="500">
	<TR bgcolor="#B2C6DE">
	<TD align="center" colSpan=6>Patient Information</TD>
	</TR>
   <tr><td width="150px">
   <font color="red">*</font> First Name: </td><td><input type="text" name="fname" size="20" value="<?php echo @$fname ?>"

   						onkeypress="return handleEnter(this, event);"

   						onKeyDown="limitText(this.form.fname,this.form.countdown9,45);" 

						onKeyUp="limitText(this.form.fname,this.form.countdown9,45);">

   </td></tr>
   <tr><td>
   <font color="red">*</font> Last Name: </td><td><input type="text" name="lname" size="20" value="<?php echo @$lname ?>"

   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.lname,this.form.countdown10,45);" 
						onKeyUp="limitText(this.form.lname,this.form.countdown10,45);">
   </td></tr>
   <tr><td>
   Phone Number: </td><td><input type="text" name="phone" size="20" value="<?php echo @$phone ?>"
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.phone,this.form.countdown11,12);" 
						onKeyUp="limitText(this.form.phone,this.form.countdown11,12);">
   </td></tr>
   <tr><td>
   Address: </td><td><input type="text" name="addr" size="20" value="<?php echo @$addr ?>"
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.addr,this.form.countdown12,80);" 
						onKeyUp="limitText(this.form.addr,this.form.countdown12,80);">
   </td></tr>
   <tr><td>
   City: </td><td><input type="text" name="city" size="20" value="<?php echo @$city ?>"
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.city,this.form.countdown13,20);" 
						onKeyUp="limitText(this.form.city,this.form.countdown13,20);">
   </td></tr>
   <tr><td>
   State: </td><td><input type="text" name="state" size="20" value="<?php echo @$state ?>"
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.state,this.form.countdown14,2);" 
						onKeyUp="limitText(this.form.state,this.form.countdown14,2);">
   </td></tr>
   <tr><td>
   Zip: </td><td><input type="text" name="zip" size="20" value="<?php echo @$zip ?>"
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.zip,this.form.countdown15,5);" 
						onKeyUp="limitText(this.form.zip,this.form.countdown15,5);">
   </td></tr>
   <tr><td>
   Email: </td><td><input type="text" name="email" size="20" value="<?php echo @$email ?>"
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.email,this.form.countdown16,50);" 
						onKeyUp="limitText(this.form.email,this.form.countdown16,50);">
   </td></tr>
   <tr><td>

   Date of Birth: </td><td><input type="text" name="dob" size="20" value="<?php echo @$dob ?>"

   						onkeypress="return handleEnter(this, event);"

   						onKeyDown="limitText(this.form.dob,this.form.countdown17,10);" 

						onKeyUp="limitText(this.form.dob,this.form.countdown17,10);">

   </td></tr>

   </table>



   <table border="1" width="500">

	<TR bgcolor="#B2C6DE">

	<TD align="center" colSpan=6>Questioner</TD>

	</TR>

   <tr><td>
	Are you interested in the following services?<br>
   <input type="checkbox" name="cardiosurgery" value="YES"> Cardiovascular Surgery<br>
   <input type="checkbox" name="schdocvisits" value="YES"> Scheduling Regular Doctor Visits<br>
   <input type="checkbox" name="homecare" value="YES"> Home Care (Housekeeping, Laundry, Meal Prep, etc.)<br>
   <input type="checkbox" name="ekgtesting" value="YES"> EKG Testing<br>
   <input type="checkbox" name="bloodwork" value="YES"> Blood Work<br>
   <input type="checkbox" name="other" > Other - Please Specify:<br>
   
   Other Information:<br>
   <textarea rows="5" cols="40" name="othermsg" 
   						onkeypress="return handleEnter(this, event);"
   						onKeyDown="limitText(this.form.othermsg,this.form.countdown18,240);" 
						onKeyUp="limitText(this.form.othermsg,this.form.countdown18,240);"
						><?php echo @$othermsg ?></textarea>

   </td></tr>
	<tr><td>How did you hear about Douglas Medical Specialists?<br>
	 <textarea rows="5" cols="40" name="howhear" 
	 					onkeypress="return handleEnter(this, event);"
	 					onKeyDown="limitText(this.form.howhear,this.form.countdown19,240);" 
						onKeyUp="limitText(this.form.howhear,this.form.countdown19,240);"
						><?php echo @$howhear ?></textarea></td></tr>
</table>
<br>
<input type="submit" name="submit" value="Click Here to Submit" style="height: 75px; width: 400px; font-size: 24px;">
   </form>
   </center>
</body>
</html>

<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||| End HTML CODE |||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -->

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Actually the 337 lines are the full project, started to go off topic with this one. Thanks for the heads up about GIT, I have been looking for a version control software for awhile.
Thanks for the points, ~Ray