Jump to content

Recommended Posts

I have a contact form that i'm trying to validate and it's saying my <li> arn't valid where I'm using them.  They need to be in <li> otherwise they go all over the place so is there another tag i can use? Or am i using the <li> wrong and how can i correct it?

 

Another thing is as warnings i get the error, how do i make the ID legal?

 

Line 76, Column 12: reference to non-existent ID "NAME".

<label for="name" class="style30">Name: <img src="required.gif" alt="requir so

 

The contact form can be viewed at

 

www.jasongold.org/contact1.php

 

The validation page can be viewed at

 

http://validator.w3.org/check?uri=www.jasongold.org%2Fcontact1.php&charset=(detect+automatically)&doctype=Inline&group=0

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<link rel="stylesheet" type="text/css"
href="portfolio.css" >
<link rel="stylesheet" type="text/css"
href="css4.css" >
<link rel="stylesheet" type="text/css"
href="contact.css" >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<title>Contact</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" >
<style type="text/css">
<!--
.style30 {color: #FFFFFF}
-->
</style>

<script type="text/javascript" src="contact.js"></script>
<!--[if IE]>
<style type="text/css" media="screen">
#menu ul li {float: left; width: 100%;}
</style>
<![endif]-->
<!--[if lt IE 7]>
<style type="text/css" media="screen">
body {
behavior: url(csshover.htc);
font-size: 100%;
} 
#menu ul li {float: left; width: 100%;}
#menu ul li a {height: 1%;}
</style>
<![endif]-->
</head>

<body id="contact">
<div class="header"></div>
<div class="logo"><img src="logo.jpg" alt="Logo" width="200" height="100" ></div>
<div class="bar1"><img src="header.jpg" alt="header" width="799" height="100"></div>
<div class="left_column" style="text-align:center">
	  <div id="menu">
		<ul id="navlist">
<li><a href="index.html" title="Link to Homepage">Home</a>
	<ul>
		<li><a href="about.html" title="Link to About Page" >About</a></li>
		<li><a href="portfolio.html" title="Link to Portfolio Page">Portfolio</a>
			<ul>
				<li><a href="fashion.html" title="Link to Fashion Page">Fashion</a></li>
				<li><a href="portrait.html" title="Link to Portrait Page">Portrait</a></li>
				<li><a href="reportage.html" title="Link to Reoportage Page">Reportage</a></li>
				<li><a href="travel.html" title="Link to Travel Page" >Travel</a></li>
			</ul>
		</li>
		<li><a href="contact1.php" title="Link to contact page" id="connav">Contact</a></li>
	</ul>
</li>
</ul>

            </div>
	</div>
<div class="about">
<fieldset>  
<legend>Contact Details</legend>  

<form onClick="highlight(event)" name="<?php echo $formname; ?>" action="<?php print PHP_SELF ?>" method='post' enctype='multipart/form-data'>
<input type='hidden' name='formmail_submit' value='Y'>
<input type='hidden' name='esh_formmail_recipient' value="<?php echo $safename; echo $atsymbol; echo $safedomain; ?>">
<input type='hidden' name='esh_formmail_cc' value="<?php echo $safeccname; echo $ccemailat; echo $safeccdomain; ?>">
<input type='hidden' name='esh_formmail_return_subject' value="<?php echo $autorespondsubject; ?>">
<input type='hidden' name='esh_formmail_return_msg' value="<?php echo $autorespondmessage; ?>">
<input type='hidden' name='esh_formmail_charset' value="">
<center><img src="required.gif" alt="required" width="12" height="12"> <font color="#FFFFFF">Denotes Required Field<br></font></center>

<?php
if( !$isHideForm ): 
	global $sErr ;
	if( $sErr ) print "<a name='error'></a><center><font class='form_error' >$sErr</font></center>"; 

	$starColor = $sErr ? "#ff0000" : "#000000";
	$style=" class='form_text' ";

?>
<li>  
<label for="name" class="style30">Name: <img src="required.gif" alt="required" width="12" height="12"></label>  
<input name="Name" onBlur="stripHTML(<?php echo $formname; ?>.Name)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "Name" ] ); ?>"> 
</li>  
<li>  
<label for="subject" class="style30">Subject: <img src="required.gif" alt="required" width="12" height="12"></label>  
<input name="esh_formmail_subject" onBlur="stripHTML(<?php echo $formname; ?>.esh_formmail_subject)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "esh_formmail_subject" ] ); ?>" > 
</li> 
<li>  
<label for="email" class="style30">Email Address: <img src="required.gif" alt="required" width="12" height="12"></label>  
<input name="Email_Address" onBlur="stripHTML(<?php echo $formname; ?>.Email_Address)" type="text" size="25" maxlength="50" value="<?php print HtmlSpecialChars( $_POST[ "Email_Address" ] ); ?>" >
</li>  
<li>  
<label for="phone" class="style30">Daytime Phone Number: <img src="required.gif" alt="required" width="12" height="12"></label>  
<input name="Daytime_Telephone" onBlur="stripHTML(<?php echo $formname; ?>.Daytime_Telephone)" type="text" size="25" maxlength="12" value="<?php print HtmlSpecialChars( $_POST[ "Daytime_Telephone" ] ); ?>" > 
</li>
<li> 
<label for="email" class="style30">Evening Phone Number: <img src="required.gif" alt="required" width="12" height="12"></label>  
<input name="Evening_Telephone" onBlur="stripHTML(<?php echo $formname; ?>.Evening_Telephone)" type="text" size="25" maxlength="12" value="<?php print HtmlSpecialChars( $_POST[ "Evening_Telephone" ] ); ?>" >  
</li>  
<li>
<label for="email" class="style30">Best way to reach you: <img src="required.gif" alt="required" width="12" height="12"></label>
<select name="Reach_Me_By">
  <option value="Email" selected="Selected" <?php  formSelected( $_POST[ "Reach_Me_By" ], "Email" ); ?>>E-mail</option>
  <option value="Daytime Telephone" <?php  formSelected( $_POST[ "Reach_Me_By" ], "Daytime Telephone" ); ?>>Daytime Telephone</option>
  <option value="Evening Telephone" <?php  formSelected( $_POST[ "Reach_Me_By" ], "Evening Telephone" ); ?>>Evening Telephone</option>
</select>
</li>
<li> 
<label for="email"><span class="style30">How did you find me: <img src="required.gif" alt="required" width="12" height="12"></span></label>  
<input name="How_I_Found_You" onBlur="stripHTML(<?php echo $formname; ?>.How_I_Found_You)" type="text" size="25" maxlength="50" value="<?php print HtmlSpecialChars( $_POST[ "How_I_Found_You" ] ); ?>" > 
</li>  
<li>
<label for="email" class="style30">Type of event:</label>  
<input name="Type_of_Event" onBlur="stripHTML(<?php echo $formname; ?>.Type_of_Event)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "Type_of_Event" ] ); ?>" > 
</li>  
<li>
<label for="email" class="style30">Date of event:</label>  
<input name="Date_of_Event" OnClick="javascript:showCal('Calendar')" onBlur="stripHTML(<?php echo $formname; ?>.Date_of_Event)" type="text" size="25" maxlength="20" value="<?php print HtmlSpecialChars( $_POST[ "Date_of_Event" ] ); ?>" >
</li>  
<li>
<label for="email" class="style30">Budget:</label>  
<select name="Budget">
  <option value="£100 - £300" selected="Selected" <?php  formSelected( $_POST[ "Budget" ], "£100 - £300" ); ?>>£100 - £300</option>
  <option value="£300 - £500" <?php  formSelected( $_POST[ "Budget" ], "£300 - £500" ); ?>>£300 - £500</option>
  <option value="£500 - £700" <?php  formSelected( $_POST[ "Budget" ], "£500 - £700" ); ?>>£500 - £700</option>
  <option value="£700 - £900" <?php  formSelected( $_POST[ "Budget" ], "£700 - £900" ); ?>>£700 - £900</option>
  <option value="£900 - £1100" <?php  formSelected( $_POST[ "Budget" ], "£900 - £1100" ); ?>>£900 - £1100</option>
  <option value="£1100+" <?php  formSelected( $_POST[ "Budget" ], "£1100+" ); ?>>£1100+</option>
</select>
</li>  
<li>
<label for="email"><span class="style30">Comments or Questions:</span>ns:</label>  
<textarea name="Comments_or_Questions" onBlur="stripHTML(<?php echo $formname; ?>.Comments_or_Questions)" cols="25" rows="3"><?php print HtmlSpecialChars( $_POST[ "Comments_or_Questions" ] ); ?></textarea> 
</li>  
<li>

    <div align="center">

      <input type="submit" name="Submit" value="Submit" >
      </div>
    </li>
</fieldset>
<?php

	if( $sErr ) print "<script language='javascript' type='text/javascript'>location.href='#error';</script>";;; 

		else:
			print( "<br><br><center><b>$thankyoumessage</b></center>" );
		endif;


?>

</div>
<span class="style1 style22"><strong></strong><strong></strong><strong></strong></span><span class="style1 style22"><span class="style6"><strong>
<div class="quotes"></div>
<div class="bar"></div>
<div class="flash"><object data="banner1.swf" type="application/x-shockwave-flash" width="999" height="100">
<param name="MOVIE" value="banner1.swf">
</object></div>
<div class="footer">
  <div align="right"></div>
</div>
</strong></span></span>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/139000-validating-php-page/
Share on other sites

here is a slightly different version that validates. I had to put <UL> tags around the LIs, change all the FOR attributes to match their input elements, add ID tags to the input elements, move the form tag up a couple lines, and remove some messy span/string garbage at the bottom:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<link rel="stylesheet" type="text/css"
href="portfolio.css" >
<link rel="stylesheet" type="text/css"
href="css4.css" >
<link rel="stylesheet" type="text/css"
href="contact.css" >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<title>Contact</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" >
<style type="text/css">
<!--
.style30 {color: #FFFFFF}
-->
</style>

<script type="text/javascript" src="contact.js"></script>
<!--[if IE]>
<style type="text/css" media="screen">
#menu ul li {float: left; width: 100%;}
</style>
<![endif]-->
<!--[if lt IE 7]>
<style type="text/css" media="screen">
body {
behavior: url(csshover.htc);
font-size: 100%;
}
#menu ul li {float: left; width: 100%;}
#menu ul li a {height: 1%;}
</style>
<![endif]-->
</head>

<body id="contact">
<div class="header"></div>
<div class="logo"><img src="logo.jpg" alt="Logo" width="200" height="100" ></div>
<div class="bar1"><img src="header.jpg" alt="header" width="799" height="100"></div>
<div class="left_column" style="text-align:center">
        <div id="menu">
         <ul id="navlist">
   <li><a href="index.html" title="Link to Homepage">Home</a>
      <ul>
         <li><a href="about.html" title="Link to About Page" >About</a></li>
         <li><a href="portfolio.html" title="Link to Portfolio Page">Portfolio</a>
            <ul>
               <li><a href="fashion.html" title="Link to Fashion Page">Fashion</a></li>
               <li><a href="portrait.html" title="Link to Portrait Page">Portrait</a></li>
               <li><a href="reportage.html" title="Link to Reoportage Page">Reportage</a></li>
               <li><a href="travel.html" title="Link to Travel Page" >Travel</a></li>
            </ul>
         </li>
         <li><a href="contact1.php" title="Link to contact page" id="connav">Contact</a></li>
      </ul>
   </li>
</ul>

            </div>
      </div>
<div class="about">
<form onClick="highlight(event)" name="<?php echo $formname; ?>" action="<?php print PHP_SELF ?>" method='post' enctype='multipart/form-data'>
<fieldset> 
<legend>Contact Details</legend> 

<input type='hidden' name='formmail_submit' value='Y'>
<input type='hidden' name='esh_formmail_recipient' value="<?php echo $safename; echo $atsymbol; echo $safedomain; ?>">
<input type='hidden' name='esh_formmail_cc' value="<?php echo $safeccname; echo $ccemailat; echo $safeccdomain; ?>">
<input type='hidden' name='esh_formmail_return_subject' value="<?php echo $autorespondsubject; ?>">
<input type='hidden' name='esh_formmail_return_msg' value="<?php echo $autorespondmessage; ?>">
<input type='hidden' name='esh_formmail_charset' value="">
<center><img src="required.gif" alt="required" width="12" height="12"> <font color="#FFFFFF">Denotes Required Field<br></font></center>

<?php
   if( !$isHideForm ): 
      global $sErr ;
      if( $sErr ) print "<a name='error'></a><center><font class='form_error' >$sErr</font></center>"; 

      $starColor = $sErr ? "#ff0000" : "#000000";
      $style=" class='form_text' ";

?>
<ul>
<li> 
<label for="Name" class="style30">Name: <img src="required.gif" alt="required" width="12" height="12"></label> 
<input name="Name" onBlur="stripHTML(<?php echo $formname; ?>.Name)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "Name" ] ); ?>">
</li> 
<li> 
<label for="esh_formmail_subject" class="style30">Subject: <img src="required.gif" alt="required" width="12" height="12"></label> 
<input name="esh_formmail_subject" id="esh_formmail_subject" onBlur="stripHTML(<?php echo $formname; ?>.esh_formmail_subject)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "esh_formmail_subject" ] ); ?>" >
</li>
<li> 
<label for="Email_Address" class="style30">Email Address: <img src="required.gif" alt="required" width="12" height="12"></label> 
<input name="Email_Address" id="Email_Address" onBlur="stripHTML(<?php echo $formname; ?>.Email_Address)" type="text" size="25" maxlength="50" value="<?php print HtmlSpecialChars( $_POST[ "Email_Address" ] ); ?>" >
</li> 
<li> 
<label for="Daytime_Telephone" class="style30">Daytime Phone Number: <img src="required.gif" alt="required" width="12" height="12"></label> 
<input name="Daytime_Telephone" id="Daytime_Telephone" onBlur="stripHTML(<?php echo $formname; ?>.Daytime_Telephone)" type="text" size="25" maxlength="12" value="<?php print HtmlSpecialChars( $_POST[ "Daytime_Telephone" ] ); ?>" >
</li>
<li>
<label for="Evening_Telephone" class="style30">Evening Phone Number: <img src="required.gif" alt="required" width="12" height="12"></label> 
<input name="Evening_Telephone" id="Evening_Telephone" onBlur="stripHTML(<?php echo $formname; ?>.Evening_Telephone)" type="text" size="25" maxlength="12" value="<?php print HtmlSpecialChars( $_POST[ "Evening_Telephone" ] ); ?>" > 
</li> 
<li>
<label for="Reach_Me_By" class="style30">Best way to reach you: <img src="required.gif" alt="required" width="12" height="12"></label>
<select name="Reach_Me_By" id="Reach_Me_By">
  <option value="Email" selected="Selected" <?php  formSelected( $_POST[ "Reach_Me_By" ], "Email" ); ?>>E-mail</option>
  <option value="Daytime Telephone" <?php  formSelected( $_POST[ "Reach_Me_By" ], "Daytime Telephone" ); ?>>Daytime Telephone</option>
  <option value="Evening Telephone" <?php  formSelected( $_POST[ "Reach_Me_By" ], "Evening Telephone" ); ?>>Evening Telephone</option>
</select>
</li>
<li>
<label for="How_I_Found_You"><span class="style30">How did you find me: <img src="required.gif" alt="required" width="12" height="12"></span></label> 
<input name="How_I_Found_You" id="How_I_Found_You" onBlur="stripHTML(<?php echo $formname; ?>.How_I_Found_You)" type="text" size="25" maxlength="50" value="<?php print HtmlSpecialChars( $_POST[ "How_I_Found_You" ] ); ?>" >
</li> 
<li>
<label for="Type_of_Event" class="style30">Type of event:</label> 
<input name="Type_of_Event" id="Type_of_Event" onBlur="stripHTML(<?php echo $formname; ?>.Type_of_Event)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "Type_of_Event" ] ); ?>" >
</li> 
<li>
<label for="Date_of_Event" class="style30">Date of event:</label> 
<input name="Date_of_Event" id="Date_of_Event" OnClick="javascript:showCal('Calendar')" onBlur="stripHTML(<?php echo $formname; ?>.Date_of_Event)" type="text" size="25" maxlength="20" value="<?php print HtmlSpecialChars( $_POST[ "Date_of_Event" ] ); ?>" >
</li> 
<li>
<label for="Budget" class="style30">Budget:</label> 
<select name="Budget" id="Budget">
  <option value="£100 - £300" selected="Selected" <?php  formSelected( $_POST[ "Budget" ], "£100 - £300" ); ?>>£100 - £300</option>
  <option value="£300 - £500" <?php  formSelected( $_POST[ "Budget" ], "£300 - £500" ); ?>>£300 - £500</option>
  <option value="£500 - £700" <?php  formSelected( $_POST[ "Budget" ], "£500 - £700" ); ?>>£500 - £700</option>
  <option value="£700 - £900" <?php  formSelected( $_POST[ "Budget" ], "£700 - £900" ); ?>>£700 - £900</option>
  <option value="£900 - £1100" <?php  formSelected( $_POST[ "Budget" ], "£900 - £1100" ); ?>>£900 - £1100</option>
  <option value="£1100+" <?php  formSelected( $_POST[ "Budget" ], "£1100+" ); ?>>£1100+</option>
</select>
</li> 
<li>
<label for="Comments_or_Questions"><span class="style30">Comments or Questions:</span>ns:</label> 
<textarea name="Comments_or_Questions" id="Comments_or_Questions" onBlur="stripHTML(<?php echo $formname; ?>.Comments_or_Questions)" cols="25" rows="3"><?php print HtmlSpecialChars( $_POST[ "Comments_or_Questions" ] ); ?></textarea>
</li> 
<li>
    <div align="center">

      <input type="submit" name="Submit" value="Submit" >
      </div>
    </li>
</ul>
</fieldset>
</form>
<?php

      if( $sErr ) print "<script language='javascript' type='text/javascript'>location.href='#error';</script>";;; 

         else:
            print( "<br><br><center><b>$thankyoumessage</b></center>" );
         endif;


?>

</div>
<div class="quotes"></div>
<div class="bar"></div>
<div class="flash"><object data="banner1.swf" type="application/x-shockwave-flash" width="999" height="100">
<param name="MOVIE" value="banner1.swf">
</object></div>
<div class="footer">
  <div align="right"></div>
</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/139000-validating-php-page/#findComment-726952
Share on other sites

Thanks for the effort i really appreciate it.  I uploaded your page and it came out with 6 errors and 1 warning http://validator.w3.org/check?uri=http%3A%2F%2Fwww.jasongold.org%2Fcontact2.php&charset=(detect+automatically)&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.606

 

Also the html is really weird, i can see it in the code then when i upload it to the server it only has half the code. You can view the page at www.jasongold.org/contact2.php

Link to comment
https://forums.phpfreaks.com/topic/139000-validating-php-page/#findComment-727064
Share on other sites

there is also this page

 

contact.config

 

<?php
//Email Name
$emailname = "contact"; // DO NOT PUT THE @, It includes itself

//Email Domain
$emaildomain = "jasongold.org"; // PUT THE .COM or Other

//Carbon Copy Email Name - Leave blank to disable
$ccemailname = ""; // DO NOT PUT THE @ after email name, It includes itself leave blank to disable.

//Carbon Copy Email Domain - Leave blank to disable
$ccemaildomain = ""; // PUT THE .COM or Other. Leave blank to disable.

//Thank You Message - Automatically set to center in the page, Don't use quotes
$thankyoumessage = "<font color=#FFFFFF> <type=Arial> Your message has been sent. Thank you.</font>";

//Autoresponder Subject - Leave blank to disable, Don't use quotes
$autorespondsubject = "Thank you for contacting us";

//Autoresponder Message - Leave blank to disable, Don't use quotes
//Make sure do not use quotes for font prefference, use   for quotes in  your message
$autorespondmessage = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please visit our website at www.jasongold.org";

//Form Name
$formname = "contactme";
?>

Link to comment
https://forums.phpfreaks.com/topic/139000-validating-php-page/#findComment-727106
Share on other sites

Is there any chance it could be in the javascript?

 

<!--

// Strip HTML Tags (form) script- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use
function stripHTML(){
var re= /<\S[^><]*>/g
for (i=0; i<arguments.length; i++)
arguments[i].value=arguments[i].value.replace(re, "")
}
// END STRIP HTML FUNCTION
//Submit Once form validation- 
//© Dynamic Drive (www.dynamicdrive.com)
//For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
//if IE 4+ or NS 6+
function submitonce(theform){

if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}

var horizontal_offset="9px"
var vertical_offset="0"
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}
// END SUBMIT ONCE FUNCTION
//Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com
var highlightcolor="#9C9A9C"
var ns6=document.getElementById&&!document.all
var previous=''
var eventobj
var intended=/INPUT|TEXTAREA/

function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}
// END HIGHLIGHT FORM ELEMENT FUNCTION
// BEGIN POPUP CALENDAR CODE
var fontFace="verdana";
var fontSize=10;

var titleWidth=90;
var titleMode=1;
var dayWidth=12;
var dayDigits=1;

var titleColor = "#000000";
var daysColor = "#333333";
var bodyColor = "#000000";
var dayColor = "#9C9A9C";
var currentDayColor = "#666666";
var footColor = "#000000";
var borderColor = "#000000";
var titleFontColor = "#FFFFFF";
var daysFontColor = "#FFFFFF";
var dayFontColor = "#FFFFFF";
var currentDayFontColor = "#FFFFFF";
var footFontColor = "#FFFFFF";

var calFormat = "dd-mm-yyyy";

var weekDay = 0;
// ------

// codes
var calWidth=200, calHeight=200, calOffsetX=-200, calOffsetY=16;
var calWin=null;
var winX=0, winY=0;
var cal="cal";
var cals=new Array();
var currentCal=null;

var yxMonths=new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var yxDays=new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
var yxLinks=new Array("[close]", "[clear]");

var nav=navigator.userAgent.toLowerCase();;
var isOpera=(nav.indexOf("opera")!=-1)?true:false;
var isOpera5=(nav.indexOf("opera 5")!=-1 || nav.indexOf("opera/5")!=-1)?true:false;
var isOpera6=(isOpera && parseInt(navigator.appVersion)>=6)?true:false;
var isN6=(nav.indexOf("gecko")!=-1);
var isN4=(document.layers)?true:false;
var isMac=(nav.indexOf("mac")!=-1);
var isIE=(document.all && !isOpera && (!isMac || navigator.appVersion.indexOf("MSIE 4")==-1))?true:false;

if (isN4) {
  fontSize+=2;
}

var span2="</span>";

function span1(tag) {
  return "<span class='"+tag+"'>";
}
function spanx(tag, color) {
  return "."+tag+" { font-family:"+fontFace+"; font-size:"+fontSize+"px; color:"+color+"; }\n";
}

function a1(tag) {
  return "<a class='"+tag+"' href=";
}

function ax(tag, color) {
  return "."+tag+" { text-decoration:none; color:"+color+"; }\n";
}

function calOBJ(name, title, field, form) {
  this.name = name;
  this.title = title;
  this.field = field;
  this.formName = form;
  this.form = null
}

function setFont(font, size) {
  if (font != "") {
    fontFace=font;
  }
  if (size > 0) {
    fontSize=size;

    if (isN4) {
      fontSize+=2;
    }
  }
}

function setWidth(tWidth, tMode, dWidth, dDigits) {
  if (tWidth > 0) {
    titleWidth=tWidth;
  }
  if (tMode == 1 || tMode == 2) {
    titleMode=tMode;
  }
  if (dWidth > 0) {
    dayWidth=dWidth;
  }
  if (dDigits > 0) {
    dayDigits=dDigits;
  }
}

function setColor(tColor, dsColor, bColor, dColor, cdColor, fColor, bdColor) {
  if (tColor != "") {
    titleColor=tColor;
  }
  if (dsColor != "") {
    daysColor=dsColor;
  }
  if (bColor != "") {
    bodyColor=bColor;
  }
  if (dColor != "") {
    dayColor=dColor;
  }
  if (cdColor != "") {
    currentDayColor=cdColor;
  }
  if (fColor != "") {
    footColor=fColor;
  }
  if (bdColor != "") {
    borderColor=bdColor;
  }
}

function setFontColor(tColorFont, dsColorFont, dColorFont, cdColorFont, fColorFont) {
  if (tColorFont != "") {
    titleFontColor=tColorFont;
  }
  if (dsColorFont != "") {
    daysFontColor=dsColorFont;
  }
  if (dColorFont != "") {
    dayFontColor=dColorFont;
  }
  if (cdColorFont != "") {
    currentDayFontColor=cdColorFont;
  }
  if (fColorFont != "") {
    footFontColor=fColorFont;
  }
}

function setFormat(format) {
  calFormat = format;
}

function setSize(width, height, ox, oy) {
  if (width > 0) {
    calWidth=width;
  }
  if (height > 0) {
    calHeight=height;
  }

  calOffsetX=ox;
  calOffsetY=oy;
}

function setWeekDay(wDay) {
  if (wDay == 0 || wDay == 1) {
    weekDay = wDay;
  }
}

function setMonthNames(janName, febName, marName, aprName, mayName, junName, julName, augName, sepName, octName, novName, decName) {
  if (janName != "") {
    yxMonths[0] = janName;
  }
  if (febName != "") {
    yxMonths[1] = febName;
  }
  if (marName != "") {
    yxMonths[2] = marName;
  }
  if (aprName != "") {
    yxMonths[3] = aprName;
  }
  if (mayName != "") {
    yxMonths[4] = mayName;
  }
  if (junName != "") {
    yxMonths[5] = junName;
  }
  if (julName != "") {
    yxMonths[6] = julName;
  }
  if (augName != "") {
    yxMonths[7] = augName;
  }
  if (sepName != "") {
    yxMonths[8] = sepName;
  }
  if (octName != "") {
    yxMonths[9] = octName;
  }
  if (novName != "") {
    yxMonths[10] = novName;
  }
  if (decName != "") {
    yxMonths[11] = decName;
  }
}

function setDayNames(sunName, monName, tueName, wedName, thuName, friName, satName) {
  if (sunName != "") {
    yxDays[0] = sunName;
    yxDays[7] = sunName;
  }
  if (monName != "") {
    yxDays[1] = monName;
  }
  if (tueName != "") {
    yxDays[2] = tueName;
  }
  if (wedName != "") {
    yxDays[3] = wedName;
  }
  if (thuName != "") {
    yxDays[4] = thuName;
  }
  if (friName != "") {
    yxDays[5] = friName;
  }
  if (satName != "") {
    yxDays[6] = satName;
  }
}

function setLinkNames(closeLink, clearLink) {
  if (closeLink != "") {
    yxLinks[0] = closeLink;
  }
  if (clearLink != "") {
    yxLinks[1] = clearLink;
  }
}

function addCalendar(name, title, field, form) {
  cals[cals.length] = new calOBJ(name, title, field, form);
}

function findCalendar(name) {
  for (var i = 0; i < cals.length; i++) {
    if (cals[i].name == name) {
      if (cals[i].form == null) {
        if (cals[i].formName == "") {
          if (document.forms[0]) {
            cals[i].form = document.forms[0];
          }
        }
        else if (document.forms[cals[i].formName]) {
          cals[i].form = document.forms[cals[i].formName];
        }
      }

      return cals[i];
    }
  }

  return null;
}

function getDayName(y,m,d) {
  var wd=new Date(y,m,d);
  return yxDays[wd.getDay()].substring(0,3);
}

function getMonthFromName(m3) {
  for (var i = 0; i < yxMonths.length; i++) {
    if (yxMonths[i].toLowerCase().substring(0,3) == m3.toLowerCase()) {
      return i;
    }
  }

  return 0;
}

function getFormat() {
  var calF = calFormat;

  calF = calF.replace(/\\/g, '\\\\');
  calF = calF.replace(/\//g, '\\\/');
  calF = calF.replace(/\[/g, '\\\[');
  calF = calF.replace(/\]/g, '\\\]');
  calF = calF.replace(/\(/g, '\\\(');
  calF = calF.replace(/\)/g, '\\\)');
  calF = calF.replace(/\{/g, '\\\{');
  calF = calF.replace(/\}/g, '\\\}');
  calF = calF.replace(/\</g, '\\\<');
  calF = calF.replace(/\>/g, '\\\>');
  calF = calF.replace(/\|/g, '\\\|');
  calF = calF.replace(/\*/g, '\\\*');
  calF = calF.replace(/\?/g, '\\\?');
  calF = calF.replace(/\+/g, '\\\+');
  calF = calF.replace(/\^/g, '\\\^');
  calF = calF.replace(/\$/g, '\\\$');

  calF = calF.replace(/dd/i, '\\d\\d');
  calF = calF.replace(/mm/i, '\\d\\d');
  calF = calF.replace(/yyyy/i, '\\d\\d\\d\\d');
  calF = calF.replace(/day/i, '\\w\\w\\w');
  calF = calF.replace(/mon/i, '\\w\\w\\w');

  return new RegExp(calF);
}

function getDateNumbers(date) {
  var y, m, d;

  var yIdx = calFormat.search(/yyyy/i);
  var mIdx = calFormat.search(/mm/i);
  var m3Idx = calFormat.search(/mon/i);
  var dIdx = calFormat.search(/dd/i);

  y=date.substring(yIdx,yIdx+4)-0;
  if (mIdx != -1) {
    m=date.substring(mIdx,mIdx+2)-1;
  }
  else {
    var m = getMonthFromName(date.substring(m3Idx,m3Idx+3));
  }
  d=date.substring(dIdx,dIdx+2)-0;

  return new Array(y,m,d);
}

function hideCal() {
  calWin.close();
  calWin = null;
  window.status = "";
}

function getLeftIE(x,m) {
  var dx=0;
  if (x.tagName=="TD"){
    dx=x.offsetLeft;
  }
  else if (x.tagName=="TABLE") {
    dx=x.offsetLeft;
    if (m) { dx+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }
  }
  return dx+(x.parentElement.tagName=="BODY"?0:getLeftIE(x.parentElement,m));
}
function getTopIE(x,m) {
  var dy=0;
  if (x.tagName=="TR"){
    dy=x.offsetTop;
  }
  else if (x.tagName=="TABLE") {
    dy=x.offsetTop;
    if (m) { dy+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }
  }
  return dy+(x.parentElement.tagName=="BODY"?0:getTopIE(x.parentElement,m));
}

function getLeftN4(l) { return l.pageX; }
function getTopN4(l) { return l.pageY; }

function getLeftN6(l) { return l.offsetLeft; }
function getTopN6(l) { return l.offsetTop; }

function lastDay(d) {
  var yy=d.getFullYear(), mm=d.getMonth();
  for (var i=31; i>=28; i--) {
    var nd=new Date(yy,mm,i);
    if (mm == nd.getMonth()) {
      return i;
    }
  }
}

function firstDay(d) {
  var yy=d.getFullYear(), mm=d.getMonth();
  var fd=new Date(yy,mm,1);
  return fd.getDay();
}

function dayDisplay(i) {
  if (dayDigits == 0) {
    return yxDays[i];
  }
  else {
    return yxDays[i].substring(0,dayDigits);
  }
}

function calTitle(d) {
  var yy=d.getFullYear(), mm=yxMonths[d.getMonth()];
  var s;

  if (titleMode == 2) {
    s="<tr align='center' bgcolor='"+titleColor+"'><td colspan='7'>\n<table cellpadding='0' cellspacing='0' border='0'><tr align='center' valign='middle'><td align='right'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-10)'> &#171;</a> "+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-1)'>&#139; </a></b>"+span2+"</td><td width='"+titleWidth+"'><b>"+span1("title")+yy+span2+"</b></td><td align='left'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(1)'> &#155;</a> "+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(10)'>&#187; </a></b>"+span2+"</td></tr><tr align='center' valign='middle'><td align='right'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.prepMonth) window.opener.prepMonth("+d.getMonth()+")'> &#139; </a></b>"+span2+"</td><td width='"+titleWidth+"'><b>"+span1("title")+mm+span2+"</b></td><td align='left'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.nextMonth) window.opener.nextMonth("+d.getMonth()+")'> &#155; </a></b>"+span2+"</td></tr></table>\n</td></tr><tr align='center' bgcolor='"+daysColor+"'>";
  }
  else {
    s="<tr align='center' bgcolor='"+titleColor+"'><td colspan='7'>\n<table cellpadding='0' cellspacing='0' border='0'><tr align='center' valign='middle'><td>"+span1("title")+"<font size='4'><b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.prepMonth) window.opener.prepMonth("+d.getMonth()+")'>&#139; </a></b>"+span2+"</td><td width='"+titleWidth+"'><nobr><b>"+span1("title")+mm+" "+yy+span2+"</b></font></nobr></td><td>"+span1("title")+"<font size='4'><b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.nextMonth) window.opener.nextMonth("+d.getMonth()+")'> &#155;</a></b></font>"+span2+"</td></tr></table>\n</td></tr><tr align='center' bgcolor='"+daysColor+"'>";
  }

  for (var i=weekDay; i<weekDay+7; i++) {
    s+="<td width='"+dayWidth+"'>"+span1("days")+dayDisplay(i)+span2+"</td>";
  }

  s+="</tr>";

  return s;
}

function calHeader() {
  return "<head>\n<title>"+currentCal.title+"</title>\n<style type='text/css'>\n"+spanx("title",titleFontColor)+spanx("days",daysFontColor)+spanx("foot",footColor)+spanx("day",dayFontColor)+spanx("currentDay",currentDayFontColor)+ax("titlea",titleFontColor)+ax("daya",dayFontColor)+ax("currenta",currentDayFontColor)+ax("foota",footFontColor)+"</style>\n</head>\n<body>\n<table align='center' border='0' bgcolor='"+borderColor+"' cellspacing='0' cellpadding='1'><tr><td>\n<table cellspacing='1' cellpadding='3' border='0'>";
}

function calFooter() {
  return "<tr bgcolor='"+footColor+"'><td colspan='7' align='center'>"+span1("foot")+"<b>"+a1("foota")+"'javascript:if (window.opener && !window.opener.closed && window.opener.hideCal) window.opener.hideCal()'>"+yxLinks[0]+"</a>  "+a1("foota")+"'javascript:if (window.opener && !window.opener.closed && window.opener.clearDate) window.opener.clearDate()'>"+yxLinks[1]+"</a></b>"+span2+"</td></tr></table>\n</td></tr></table>\n</body>";
}

function calBody(d,day) {
  var s="", dayCount=1, fd=firstDay(d), ld=lastDay(d);

  if (weekDay > 0 && fd == 0) {
    fd = 7;
  }

  for (var i=0; i<6; i++) {
    s+="<tr align='center' bgcolor='"+bodyColor+"'>";
    for (var j=weekDay; j<weekDay+7; j++) {
      if (i*7+j<fd || dayCount>ld) {
        s+="<td>"+span1("day")+" "+span2+"</td>";
      }
      else {
        var bgColor=dayColor;
        var fgTag="day";
        var fgTagA="daya";
        if (dayCount==day) { 
          bgColor=currentDayColor; 
          fgTag="currentDay";
          fgTagA="currenta";
        }
        
        s+="<td bgcolor='"+bgColor+"'>"+span1(fgTag)+a1(fgTagA)+"'javascript: if (window.opener && !window.opener.closed && window.opener.pickDate) window.opener.pickDate("+dayCount+")'>"+(dayCount++)+"</a>"+span2+"</td>";
      }
    }
    s+="</tr>";
  }

  return s;
}

function moveYear(dy) {
  cY+=dy;
  var nd=new Date(cY,cM,1);
  changeCal(nd);
}

function prepMonth(m) {
  cM=m-1;
  if (cM<0) { cM=11; cY--; }
  var nd=new Date(cY,cM,1);
  changeCal(nd);
}

function nextMonth(m) {
  cM=m+1;
  if (cM>11) { cM=0; cY++;}
  var nd=new Date(cY,cM,1);
  changeCal(nd);
}

function changeCal(d) {
  var dd = 0;

  if (currentCal != null) {
    var calRE = getFormat();

    if (currentCal.form[currentCal.field].value!="" && calRE.test(currentCal.form[currentCal.field].value)) {
      var cd = getDateNumbers(currentCal.form[currentCal.field].value);
      if (cd[0] == d.getFullYear() && cd[1] == d.getMonth()) {
        dd=cd[2];
      }
    }
    else {
      var cd = new Date();
      if (cd.getFullYear() == d.getFullYear() && cd.getMonth() == d.getMonth()) {
        dd=cd.getDate();
      }
    }
  }

  var calendar=calHeader()+calTitle(d)+calBody(d,dd)+calFooter();

  calWin.document.open();
  calWin.document.write(calendar);
  calWin.document.close();
}

function markClick(e) {
  if (isIE || isOpera6) {
    winX=event.screenX;
    winY=event.screenY;
  }
  else if (isN4 || isN6) {
    winX=e.screenX;
    winY=e.screenY;

    document.routeEvent(e);
  }

  if (isN4 || isN6) { 
    document.routeEvent(e); 
  } 
  else { 
    event.cancelBubble=false; 
  } 

  return true;
}

function showCal(name) {
  var lastCal=currentCal;
  var d=new Date(), hasCal=false;

  currentCal = findCalendar(name);

  if (currentCal != null && currentCal.form != null && currentCal.form[currentCal.field]) {
    var calRE = getFormat();

    if (currentCal.form[currentCal.field].value!="" && calRE.test(currentCal.form[currentCal.field].value)) {
      var cd = getDateNumbers(currentCal.form[currentCal.field].value);
      d=new Date(cd[0],cd[1],cd[2]);

      cY=cd[0];
      cM=cd[1];
      dd=cd[2];
    }
    else {
      cY=d.getFullYear();
      cM=d.getMonth();
      dd=d.getDate();
    }

    var calendar=calHeader()+calTitle(d)+calBody(d,dd)+calFooter();

    if (calWin != null && typeof(calWin.closed)!="undefined" && !calWin.closed) {
      hasCal=true;
      calWin.moveTo(winX+calOffsetX,winY+calOffsetY);
    }

    if (!hasCal) {
      if (isIE || isOpera6) {
        calWin=window.open("","cal","toolbar=0,width="+calWidth+",height="+calHeight+",left="+(winX+calOffsetX)+",top="+(winY+calOffsetY));
      }
      else {
        calWin=window.open("","cal","toolbar=0,width="+calWidth+",height="+calHeight+",screenx="+(winX+calOffsetX)+",screeny="+(winY+calOffsetY));
      }
    }

    calWin.document.open();
    calWin.document.write(calendar);
    calWin.document.close();

    calWin.focus();
  }
  else {
    if (currentCal == null) {
      window.status = "Calendar ["+name+"] not found.";
    }
    else if (!currentCal.form) {
      window.status = "Form ["+currentCal.formName+"] not found.";
    }
    else if (!currentCal.form[currentCal.field]) {
      window.status = "Form Field ["+currentCal.formName+"."+currentCal.field+"] not found.";
    }

    if (lastCal != null) {
      currentCal = lastCal;
    }
  }
}

function get2Digits(n) {
  return ((n<10)?"0":"")+n;
}

function clearDate() {
  currentCal.form[currentCal.field].value="";
  hideCal();
}

function pickDate(d) {
  hideCal();
  window.focus();

  var date=calFormat;
  date = date.replace(/yyyy/i, cY);
  date = date.replace(/mm/i, get2Digits(cM+1));
  date = date.replace(/MON/, yxMonths[cM].substring(0,3).toUpperCase());
  date = date.replace(/Mon/i, yxMonths[cM].substring(0,3));
  date = date.replace(/dd/i, get2Digits(d));
  date = date.replace(/DAY/, getDayName(cY,cM,d).toUpperCase());
  date = date.replace(/day/i, getDayName(cY,cM,d));

  currentCal.form[currentCal.field].value=date;
  // IE5/Mac needs focus to show the value, weird.
  currentCal.form[currentCal.field].focus();
}
// ------

// user functions
function checkDate(name) {
  var thisCal = findCalendar(name);

  if (thisCal != null && thisCal.form != null && thisCal.form[thisCal.field]) {
    var calRE = getFormat();

    if (calRE.test(thisCal.form[thisCal.field].value)) {
      return 0;
    }
    else {
      return 1;
    }
  }
  else {
    return 2;
  }
}

function getCurrentDate() {
  var date=calFormat, d = new Date();
  date = date.replace(/yyyy/i, d.getFullYear());
  date = date.replace(/mm/i, get2Digits(d.getMonth()+1));
  date = date.replace(/dd/i, get2Digits(d.getDate()));

  return date;
}

function compareDates(date1, date2) {
  var calRE = getFormat();
  var d1, d2;

  if (calRE.test(date1)) {
    d1 = getNumbers(date1);
  }
  else {
    d1 = getNumbers(getCurrentDate());
  }

  if (calRE.test(date2)) {
    d2 = getNumbers(date2);
  }
  else {
    d2 = getNumbers(getCurrentDate());
  }

  var dStr1 = d1[0] + "" + d1[1] + "" + d1[2];
  var dStr2 = d2[0] + "" + d2[1] + "" + d2[2];

  if (dStr1 == dStr2) {
    return 0;
  }
  else if (dStr1 > dStr2) {
    return 1;
  }
  else {
    return -1;
  }
}

function getNumbers(date) {
  var calRE = getFormat();
  var y, m, d;

  if (calRE.test(date)) {
    var yIdx = calFormat.search(/yyyy/i);
    var mIdx = calFormat.search(/mm/i);
    var m3Idx = calFormat.search(/mon/i);
    var dIdx = calFormat.search(/dd/i);

    y=date.substring(yIdx,yIdx+4);
    if (mIdx != -1) {
      m=date.substring(mIdx,mIdx+2);
    }
    else {
      var mm=getMonthFromName(date.substring(m3Idx,m3Idx+3))+1;
      m=(mm<10)?("0"+mm)""+mm);
    }
    d=date.substring(dIdx,dIdx+2);

    return new Array(y,m,d);
  }
  else {
    return new Array("", "", "");
  }
}
// ------

if (isN4 || isN6) {
  document.captureEvents(Event.CLICK);
}
document.onclick=markClick;


//Define calendar(s): addCalendar ("Unique Calendar Name", "Window title", "Form element's name", Form name")
addCalendar("Calendar", "Date of Event", "Date_of_Event", "<? echo $formname; ?>");//-->

 

If it's not in there then i'm not sure what else to look for as i only have that php/html page, contact.config and the javascript for it.

Link to comment
https://forums.phpfreaks.com/topic/139000-validating-php-page/#findComment-727120
Share on other sites

the php/html page as well as it wouldn't all fit in one page.

 

<?php
include_once( "contact.config.php" );

$atsymbol = "@"; $safename = $emailname; $safedomain = $emaildomain;
$safeccname = $ccemailname; $safeccdomain = $ccemaildomain;
if (empty ($ccemailname)) { $ccemailat = ""; } else { $ccemailat = $atsymbol; }

define( "BUG_REPORT", "barrym@owt200x.us" );
define( "HOST_NAME", getEnv( "HTTP_HOST" ) );
define( "PHP_SELF", getEnv( "SCRIPT_NAME" ) );
define( "ERR_MISSING", "Missing Required Field: " );
define( "ERR_EMAIL", "Invalid " );
define( "ERR_SELECT_UPLOAD", "Please Select Upload File<br>" );

error_reporting( E_ERROR | E_WARNING | E_PARSE );

$form_mail[] = array( "name" => "Name", "text" => "Name",  "type" => "text", "required" => "Required" ) ;
$form_mail[] = array( "name" => "esh_formmail_subject", "text" => "Subject",  "type" => "text", "required" => "Required" ) ;
$form_mail[] = array( "name" => "Email_Address", "text" => "Email Address",  "type" => "sender's email", "required" => "Required" ) ;
$form_mail[] = array( "name" => "Daytime_Telephone", "text" => "Daytime Telephone",  "type" => "text", "required" => "Required" ) ;
$form_mail[] = array( "name" => "Evening_Telephone", "text" => "Evening Telephone",  "type" => "text", "required" => "Required" ) ;
$form_mail[] = array( "name" => "Reach_Me_By", "text" => "Reach Me By",  "type" => "select", "required" => "Required" ) ;
$form_mail[] = array( "name" => "How_I_Found_You", "text" => "How I Found You",  "type" => "text", "required" => "Required" ) ;
$form_mail[] = array( "name" => "Type_of_Event", "text" => "Type of Event",  "type" => "text", "required" => "" ) ;
$form_mail[] = array( "name" => "Date_of_Event", "text" => "Date of Event",  "type" => "text", "required" => "" ) ;
$form_mail[] = array( "name" => "Budget", "text" => "Budget",  "type" => "select", "required" => "" ) ;
$form_mail[] = array( "name" => "Comments_or_Questions", "text" => "Comments or Questions",  "type" => "textarea", "required" => "" ) ;

$isHideForm = false;

if( $_POST["formmail_submit"])
{
$sErr = checkPass();
if( ! $sErr ){
	sendFormMail( $form_mail, "") ;
	$isHideForm = true;

	$redirect = "";
	if( strlen(trim($redirect)) ):
		header( "Location:$redirect" );
		exit;
	endif;
}
}	

function sendFormMail( $form_mail, $sFileName = ""  ) 
{ 
    global $_POST ; 

$to = $_POST["esh_formmail_recipient"];
$from = "online.submit@" . HOST_NAME ;
$subject = $_POST["esh_formmail_subject"];
$sWhatToDo = $sFileName ? "mailandfile" : "" ;
$cc = $_POST["esh_formmail_cc"];
$bcc = $_POST["esh_formmail_bcc"];
$charset = $_POST["esh_formmail_charset"];

    for( $i = 0; $i < count( $form_mail ); $i ++ ){ 
        $value = trim( $_POST[ $form_mail[ $i ][ "name" ] ] ); 
        $content .= $form_mail[ $i ][ "text" ] . " \t : " . $value ."\n"; 
        $line .= remove_newline( $value ) . "\t" ; 
	if( strtolower("Sender's email") == strtolower($form_mail[ $i ][ "type" ]) ) {

		$from = $value ;
	}
    };
    $content .= "\n\nIP:" . getEnv( "REMOTE_ADDR" ); 

switch( strtolower($sWhatToDo) ){
	case "mailandfile" :
        mailAttachments( $to , $subject , $content,  $from,  $charset, $cc , $bcc ) ; 
    	    if( ! appendToFile( $sFileName, $line ) ) 
			mailReport( $content . "\n\nWrite Form Mail to File Fail." ); 
		break;			

	case "fileonly" :
    	    if( ! appendToFile( $sFileName, $line ) ) 
			mailReport( $content . "\n\nWrite Form Mail to File Fail.", $from ); 
		break;

	default :
        mailAttachments( $to , $subject , $content,  $from,  $charset, $cc , $bcc ) ; 
} 

mailAutoResponse( $from ) ;
} 

function mailAutoResponse( $to ){
    global    $_POST ; 
$subject = $_POST["esh_formmail_return_subject"];
$responseMsg = $_POST["esh_formmail_return_msg"];
if( $to && $responseMsg ) 
	mail( $to, $subject, $responseMsg, "From: " . $_POST["esh_formmail_recipient"] );
}

function mailReport( $content = "", $from = "" ){
mail( BUG_REPORT, "Error@" . HOST_NAME . PHP_SELF, $content, "From:$from" );
}

function remove_newline( $str = "" ){
$newliner = "<!--esh_newline-->" ;
$newtaber = "<!--esh_newtaber-->" ;
$str = ereg_replace( "\t", $newtaber, $str );
$str = ereg_replace( "\r\n", $newliner, $str );
return ereg_replace( "\n", $newliner, $str );
}

function checkPass()
{
global	$form_mail ;
global	$_POST ;
    global  $HTTP_POST_FILES ; 

for( $i = 0; $i < count( $form_mail ); $i ++ ){
	$type = strtolower( $form_mail[ $i ][ "type" ]  );
	$value = trim( $_POST[ $form_mail[ $i ][ "name" ] ] );
	$required = $form_mail[ $i ][ "required" ] ;
	$text = stripslashes( $form_mail[ $i ][ "text" ] );

	if( !strlen($value) && (  $required == "Required" ) && $type != "attachment" )   
		return ERR_MISSING . $text  ;

	if( 
		( strlen($value) || $type == "attachment" ) 
		&&  $required == "Required" 
	):
		switch( $type ){
				case 	strtolower("Sender's Name") :
						  break;
				case 	strtolower("Generic email"):
				case 	strtolower("Sender's email"):
						   if( ! formIsEMail($value) )	 return ERR_EMAIL . $text ;
						   break;
				case	"text" :
							break;
				case 	"textarea" :
							break;
				case	"checkbox" :
				case 	"radio" :
							break;
				case 	"select" :
							break;
				case 	"attachment" :
					$upload_file = $HTTP_POST_FILES[ $form_mail[ $i ]["name"] ][ "tmp_name" ] ;
							if( ! is_uploaded_file($upload_file)  )
								return  ERR_SELECT_UPLOAD . $text; 
							break;
				case strtolower("Time(HH:MM:SS)"):
							break;
				case strtolower("Time(HH:MM)"):
							break;
				default :

			}
	endif;
}

return "" ;
}

function formSelected( $var, $val ) 
{ 
    echo ( $var == $val ) ? "selected" : ""; 
} 

function formChecked( $var, $val ) 
{ 
    echo ( $var == $val ) ? "checked" : ""; 
} 

function formIsEMail( $email ){ 
        return ereg( "^(.+)@(.+)\\.(.+)$", $email ); 
} 

function selectList( $name, $selectedValue, $start, $end, $prompt = "-Select-", $style = "" ) 
{ 
    $tab = "\t" ; 
    print "<select name=\"$name\" $style>\n" ; 
    print $tab . "<option value=''>$prompt</option>\n" ; 
    $nLen = strlen( "$end" ) ; 
    $prefix_zero = str_repeat( "0", $nLen ); 
    for( $i = $start; $i <= $end ; $i ++ ){ 
        $stri = substr( $prefix_zero . $i, strlen($prefix_zero . $i)-$nLen, $nLen ); 
        $selected = ( $stri == $selectedValue ) ? " selected " : "" ; 
        print $tab . "<option value=\"$stri\" $selected >$stri</option>\n" ; 
    } 
    print "</select>\n\n" ; 
} 

function mailAttachments( $to = "" , $subject = "" , $message = "" , $from = "barrym@owt200x.us" , $charset = "iso-8859-1", $cc = "" , $bcc = "" ){ 
    global $HTTP_POST_FILES ; 
     
        if( ! strlen( trim( $to ) ) ) return "Missing \"To\" Field." ; 

        $boundary = "====_OwT_PHP_Contact_Form_" . md5( uniqid( srand( time() ) ) ) . "====";  

        $headers = "From: $from\r\n";  
        if ($cc) $headers .= "CC: $cc\r\n";  
        if ($bcc) $headers .= "BCC: $bcc\r\n";  
	$plainHeaders = $headers ;
        $headers .= "MIME-Version: 1.0\nContent-type: multipart/mixed;\n\tboundary=\"$boundary\"\n";  

        $txtMsg = "\nThis is a multi-part message in MIME format.\n" .  
                        "\n--$boundary\n" . 
                        "Content-Type: text/plain;\n\tcharset=\"$charset\"\n\n"  . $message . "\n"; 
         
        $sError = "" ; 
        $nFound = 0; 
        foreach( $HTTP_POST_FILES as $aFile ){ 
                    $sFileName = $aFile[ "tmp_name" ] ; 
                    $sFileRealName = $aFile[ "name" ] ; 
                    if( is_file( $sFileName ) ): 
                         
                        if( $fp = fopen( $sFileName, "rb" ) ) : 
                            $sContent = fread( $fp, filesize( $sFileName ) ); 
                            $sFName = basename( $sFileRealName ) ; 
                            $sMIME = getMIMEType( $sFName ) ; 
                             
                            $bPlainText = ( $sMIME == "text/plain" ) ; 
                            if( $bPlainText ) : 
                                $encoding = "" ; 
                            else: 
                                $encoding = "Content-Transfer-Encoding: base64\n";  
                                $sContent = chunk_split( base64_encode( $sContent ) );  
                            endif; 
                             
                            $sEncodeBody .=     "\n--$boundary\n" .  
                                                        "Content-Type: $sMIME;\n" .  
                                                        "\tname=\"$sFName\"\n" . 
                                                        $encoding .  
                                                        "Content-Disposition: attachment;\n" .  
                                                        "\tfilename=\"$sFName\"\n\n" . 
                                                        $sContent . "\n" ; 
                            $nFound ++;                                                 
                        else: 
                            $sError .= "<br>File $sFileName can not open.\n" ; 
                        endif;
                         
                    else: 
                        $sError .= "<br>File $sFileName doesn't exist.\n" ; 
                    endif;
        };
   
         $sEncodeBody .= "\n\n--$boundary--" ; 
         $sSource = $txtMsg . $sEncodeBody ; 


	 $nFound ? mail( $to, $subject, $sSource, $headers  )
	                : mail( $to, $subject, $message, $plainHeaders );  

        return $sError ;         
} 

function getMIMEType( $sFileName = "" ) { 
         
        $sFileName = strtolower( trim( $sFileName ) ); 
        if( ! strlen( $sFileName  ) ) return ""; 
         
        $aMimeType = array(  
                                        "txt" => "text/plain" , 
                                        "pdf" => "application/pdf" , 
                                        "zip" => "application/x-compressed" , 

                                        "html" => "text/html" , 
                                        "htm" => "text/html" , 

                                        "avi" => "video/avi" , 
                                        "mpg" => "video/mpeg " , 
                                        "wav" => "audio/wav" , 

                                        "jpg" => "image/jpeg " , 
                                        "gif" => "image/gif" , 
                                        "tif" => "image/tiff " , 
                                        "png" => "image/x-png" , 
                                        "bmp" => "image/bmp"  
                                    ); 
        $aFile = split( "\.", basename( $sFileName ) ) ; 
        $nDiminson = count( $aFile ) ; 
         $sExt = $aFile[ $nDiminson - 1 ] ;
         
        return ( $nDiminson > 1 ) ? $aMimeType[ $sExt ] : "";  
} 

function appendToFile( $sFileName = "", $line = "" ){ 
    if( !$sFileName || !$line ) return 0; 
    $hFile = fopen( "$sFileName", "a+w" ); 
    $nBytes = 0; 
    if( $hFile ){ 
        $nBytes = fputs( $hFile , trim($line)."\r\n" ); 
        fclose( $hFile ); 
    }; 
    return $nBytes ; 
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<link rel="stylesheet" type="text/css"
href="portfolio.css" >
<link rel="stylesheet" type="text/css"
href="css4.css" >
<link rel="stylesheet" type="text/css"
href="contact.css" >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<title>Contact</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" >
<style type="text/css">
<!--
.style30 {color: #FFFFFF}
-->
</style>

<script type="text/javascript" src="contact.js"></script>
<!--[if IE]>
<style type="text/css" media="screen">
#menu ul li {float: left; width: 100%;}
</style>
<![endif]-->
<!--[if lt IE 7]>
<style type="text/css" media="screen">
body {
behavior: url(csshover.htc);
font-size: 100%;
} 
#menu ul li {float: left; width: 100%;}
#menu ul li a {height: 1%;}
</style>
<![endif]-->
</head>

<body id="contact">
<div class="header"></div>
<div class="logo"><img src="logo.jpg" alt="Logo" width="200" height="100" ></div>
<div class="bar1"><img src="header.jpg" alt="header" width="799" height="100"></div>
<div class="left_column" style="text-align:center">
	  <div id="menu">
		<ul id="navlist">
<li><a href="index.html" title="Link to Homepage">Home</a>
	<ul>
		<li><a href="about.html" title="Link to About Page" >About</a></li>
		<li><a href="portfolio.html" title="Link to Portfolio Page">Portfolio</a>
			<ul>
				<li><a href="fashion.html" title="Link to Fashion Page">Fashion</a></li>
				<li><a href="portrait.html" title="Link to Portrait Page">Portrait</a></li>
				<li><a href="reportage.html" title="Link to Reoportage Page">Reportage</a></li>
				<li><a href="travel.html" title="Link to Travel Page" >Travel</a></li>
			</ul>
		</li>
		<li><a href="contact1.php" title="Link to contact page" id="connav">Contact</a></li>
	</ul>
</li>
</ul>

  </div>
</div>
<div class="about">
<fieldset>  
<legend>Contact Details</legend>  

<form onClick="highlight(event)" name="<?php echo $formname; ?>" action="<?php print PHP_SELF ?>" method='post' enctype='multipart/form-data'>
<input type='hidden' name='formmail_submit' value='Y'>
<input type='hidden' name='esh_formmail_recipient' value="<?php echo $safename; echo $atsymbol; echo $safedomain; ?>">
<input type='hidden' name='esh_formmail_cc' value="<?php echo $safeccname; echo $ccemailat; echo $safeccdomain; ?>">
<input type='hidden' name='esh_formmail_return_subject' value="<?php echo $autorespondsubject; ?>">
<input type='hidden' name='esh_formmail_return_msg' value="<?php echo $autorespondmessage; ?>">
<input type='hidden' name='esh_formmail_charset' value="">
<center><img src="required.gif" alt="required" width="12" height="12"> <font color="#FFFFFF">Denotes Required Field<br></font></center>

<?php
if( !$isHideForm ): 
	global $sErr ;
	if( $sErr ) print "<a name='error'></a><center><font class='form_error' >$sErr</font></center>"; 

	$starColor = $sErr ? "#ff0000" : "#000000";
	$style=" class='form_text' ";

?>
<ul>
<li>  
<label for="name" class="style30">Name: <img src="required.gif" alt="required" width="12" height="12"></label>  
<input name="Name" onBlur="stripHTML(<?php echo $formname; ?>.Name)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "Name" ] ); ?>"> 
</li>  
<li>  
<label for="subject" class="style30">Subject: <img src="required.gif" alt="required" width="12" height="12"></label>  
<input name="esh_formmail_subject" onBlur="stripHTML(<?php echo $formname; ?>.esh_formmail_subject)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "esh_formmail_subject" ] ); ?>" > 
</li> 
<li>  
<label for="email" class="style30">Email Address: <img src="required.gif" alt="required" width="12" height="12"></label>  
<input name="Email_Address" onBlur="stripHTML(<?php echo $formname; ?>.Email_Address)" type="text" size="25" maxlength="50" value="<?php print HtmlSpecialChars( $_POST[ "Email_Address" ] ); ?>" >
</li>  
<li>  
<label for="phone" class="style30">Daytime Phone Number: <img src="required.gif" alt="required" width="12" height="12"></label>  
<input name="Daytime_Telephone" onBlur="stripHTML(<?php echo $formname; ?>.Daytime_Telephone)" type="text" size="25" maxlength="12" value="<?php print HtmlSpecialChars( $_POST[ "Daytime_Telephone" ] ); ?>" > 
</li>
<li> 
<label for="email" class="style30">Evening Phone Number: <img src="required.gif" alt="required" width="12" height="12"></label>  
<input name="Evening_Telephone" onBlur="stripHTML(<?php echo $formname; ?>.Evening_Telephone)" type="text" size="25" maxlength="12" value="<?php print HtmlSpecialChars( $_POST[ "Evening_Telephone" ] ); ?>" >  
</li>  
<li>
<label for="email" class="style30">Best way to reach you: <img src="required.gif" alt="required" width="12" height="12"></label>
<select name="Reach_Me_By">
  <option value="Email" selected="Selected" <?php  formSelected( $_POST[ "Reach_Me_By" ], "Email" ); ?>>E-mail</option>
  <option value="Daytime Telephone" <?php  formSelected( $_POST[ "Reach_Me_By" ], "Daytime Telephone" ); ?>>Daytime Telephone</option>
  <option value="Evening Telephone" <?php  formSelected( $_POST[ "Reach_Me_By" ], "Evening Telephone" ); ?>>Evening Telephone</option>
</select>
</li>
<li> 
<label for="email"><span class="style30">How did you find me: <img src="required.gif" alt="required" width="12" height="12"></span></label>  
<input name="How_I_Found_You" onBlur="stripHTML(<?php echo $formname; ?>.How_I_Found_You)" type="text" size="25" maxlength="50" value="<?php print HtmlSpecialChars( $_POST[ "How_I_Found_You" ] ); ?>" > 
</li>  
<li>
<label for="email" class="style30">Type of event:</label>  
<input name="Type_of_Event" onBlur="stripHTML(<?php echo $formname; ?>.Type_of_Event)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "Type_of_Event" ] ); ?>" > 
</li>  
<li>
<label for="email" class="style30">Date of event:</label>  
<input name="Date_of_Event" OnClick="javascript:showCal('Calendar')" onBlur="stripHTML(<?php echo $formname; ?>.Date_of_Event)" type="text" size="25" maxlength="20" value="<?php print HtmlSpecialChars( $_POST[ "Date_of_Event" ] ); ?>" >
</li>  
<li>
<label for="email" class="style30">Budget:</label>  
<select name="Budget">
  <option value="£100 - £300" selected="Selected" <?php  formSelected( $_POST[ "Budget" ], "£100 - £300" ); ?>>£100 - £300</option>
  <option value="£300 - £500" <?php  formSelected( $_POST[ "Budget" ], "£300 - £500" ); ?>>£300 - £500</option>
  <option value="£500 - £700" <?php  formSelected( $_POST[ "Budget" ], "£500 - £700" ); ?>>£500 - £700</option>
  <option value="£700 - £900" <?php  formSelected( $_POST[ "Budget" ], "£700 - £900" ); ?>>£700 - £900</option>
  <option value="£900 - £1100" <?php  formSelected( $_POST[ "Budget" ], "£900 - £1100" ); ?>>£900 - £1100</option>
  <option value="£1100+" <?php  formSelected( $_POST[ "Budget" ], "£1100+" ); ?>>£1100+</option>
</select>
</li>  
<li>
<label for="email"><span class="style30">Comments or Questions:</span>ns:</label>  
<textarea name="Comments_or_Questions" onBlur="stripHTML(<?php echo $formname; ?>.Comments_or_Questions)" cols="25" rows="3"><?php print HtmlSpecialChars( $_POST[ "Comments_or_Questions" ] ); ?></textarea> 
</li>  
<li>

    <div align="center">

      <input type="submit" name="Submit" value="Submit" >
    </div>
</ul>
    

<?php

	if( $sErr ) print "<script language='javascript' type='text/javascript'>location.href='#error';</script>";;; 

		else:
			print( "<br><br><center><b>$thankyoumessage</b></center>" );
		endif;


?>

</div>
<span class="style1 style22"><strong></strong><strong></strong><strong></strong></span><span class="style1 style22"><span class="style6"><strong>
<div class="quotes"></div>
<div class="bar"></div>
<div class="flash"><object data="banner1.swf" type="application/x-shockwave-flash" width="999" height="100">
<param name="MOVIE" value="banner1.swf">
</object></div>
<div class="footer">
  <div align="right"></div>
</div>
</strong></span></span>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/139000-validating-php-page/#findComment-727122
Share on other sites

there you go...now it's defined....merge the two codes together and we get:

 

<?php
include_once( "contact.config.php" );

$atsymbol = "@"; $safename = $emailname; $safedomain = $emaildomain;
$safeccname = $ccemailname; $safeccdomain = $ccemaildomain;
if (empty ($ccemailname)) { $ccemailat = ""; } else { $ccemailat = $atsymbol; }

define( "BUG_REPORT", "barrym@owt200x.us" );
define( "HOST_NAME", getEnv( "HTTP_HOST" ) );
define( "PHP_SELF", getEnv( "SCRIPT_NAME" ) );
define( "ERR_MISSING", "Missing Required Field: " );
define( "ERR_EMAIL", "Invalid " );
define( "ERR_SELECT_UPLOAD", "Please Select Upload File<br>" );

error_reporting( E_ERROR | E_WARNING | E_PARSE );

$form_mail[] = array( "name" => "Name", "text" => "Name",  "type" => "text", "required" => "Required" ) ;
$form_mail[] = array( "name" => "esh_formmail_subject", "text" => "Subject",  "type" => "text", "required" => "Required" ) ;
$form_mail[] = array( "name" => "Email_Address", "text" => "Email Address",  "type" => "sender's email", "required" => "Required" ) ;
$form_mail[] = array( "name" => "Daytime_Telephone", "text" => "Daytime Telephone",  "type" => "text", "required" => "Required" ) ;
$form_mail[] = array( "name" => "Evening_Telephone", "text" => "Evening Telephone",  "type" => "text", "required" => "Required" ) ;
$form_mail[] = array( "name" => "Reach_Me_By", "text" => "Reach Me By",  "type" => "select", "required" => "Required" ) ;
$form_mail[] = array( "name" => "How_I_Found_You", "text" => "How I Found You",  "type" => "text", "required" => "Required" ) ;
$form_mail[] = array( "name" => "Type_of_Event", "text" => "Type of Event",  "type" => "text", "required" => "" ) ;
$form_mail[] = array( "name" => "Date_of_Event", "text" => "Date of Event",  "type" => "text", "required" => "" ) ;
$form_mail[] = array( "name" => "Budget", "text" => "Budget",  "type" => "select", "required" => "" ) ;
$form_mail[] = array( "name" => "Comments_or_Questions", "text" => "Comments or Questions",  "type" => "textarea", "required" => "" ) ;

$isHideForm = false;

if( $_POST["formmail_submit"])
   {
   $sErr = checkPass();
   if( ! $sErr ){
      sendFormMail( $form_mail, "") ;
      $isHideForm = true;
      
      $redirect = "";
      if( strlen(trim($redirect)) ):
         header( "Location:$redirect" );
         exit;
      endif;
   }
}   

function sendFormMail( $form_mail, $sFileName = ""  ) 
{ 
    global $_POST ; 
   
   $to = $_POST["esh_formmail_recipient"];
   $from = "online.submit@" . HOST_NAME ;
   $subject = $_POST["esh_formmail_subject"];
   $sWhatToDo = $sFileName ? "mailandfile" : "" ;
   $cc = $_POST["esh_formmail_cc"];
   $bcc = $_POST["esh_formmail_bcc"];
   $charset = $_POST["esh_formmail_charset"];
   
    for( $i = 0; $i < count( $form_mail ); $i ++ ){ 
        $value = trim( $_POST[ $form_mail[ $i ][ "name" ] ] ); 
        $content .= $form_mail[ $i ][ "text" ] . " \t : " . $value ."\n"; 
        $line .= remove_newline( $value ) . "\t" ; 
      if( strtolower("Sender's email") == strtolower($form_mail[ $i ][ "type" ]) ) {

         $from = $value ;
      }
    };
    $content .= "\n\nIP:" . getEnv( "REMOTE_ADDR" ); 

   switch( strtolower($sWhatToDo) ){
      case "mailandfile" :
           mailAttachments( $to , $subject , $content,  $from,  $charset, $cc , $bcc ) ; 
           if( ! appendToFile( $sFileName, $line ) ) 
            mailReport( $content . "\n\nWrite Form Mail to File Fail." ); 
         break;         

      case "fileonly" :
           if( ! appendToFile( $sFileName, $line ) ) 
            mailReport( $content . "\n\nWrite Form Mail to File Fail.", $from ); 
         break;

      default :
           mailAttachments( $to , $subject , $content,  $from,  $charset, $cc , $bcc ) ; 
   } 

   mailAutoResponse( $from ) ;
} 

function mailAutoResponse( $to ){
    global    $_POST ; 
   $subject = $_POST["esh_formmail_return_subject"];
   $responseMsg = $_POST["esh_formmail_return_msg"];
   if( $to && $responseMsg ) 
      mail( $to, $subject, $responseMsg, "From: " . $_POST["esh_formmail_recipient"] );
}

function mailReport( $content = "", $from = "" ){
   mail( BUG_REPORT, "Error@" . HOST_NAME . PHP_SELF, $content, "From:$from" );
}

function remove_newline( $str = "" ){
   $newliner = "<!--esh_newline-->" ;
   $newtaber = "<!--esh_newtaber-->" ;
   $str = ereg_replace( "\t", $newtaber, $str );
   $str = ereg_replace( "\r\n", $newliner, $str );
   return ereg_replace( "\n", $newliner, $str );
}

function checkPass()
{
   global   $form_mail ;
   global   $_POST ;
    global  $HTTP_POST_FILES ; 

   for( $i = 0; $i < count( $form_mail ); $i ++ ){
      $type = strtolower( $form_mail[ $i ][ "type" ]  );
      $value = trim( $_POST[ $form_mail[ $i ][ "name" ] ] );
      $required = $form_mail[ $i ][ "required" ] ;
      $text = stripslashes( $form_mail[ $i ][ "text" ] );

      if( !strlen($value) && (  $required == "Required" ) && $type != "attachment" )   
         return ERR_MISSING . $text  ;

      if( 
         ( strlen($value) || $type == "attachment" ) 
         &&  $required == "Required" 
      ):
         switch( $type ){
               case    strtolower("Sender's Name") :
                       break;
               case    strtolower("Generic email"):
               case    strtolower("Sender's email"):
                        if( ! formIsEMail($value) )    return ERR_EMAIL . $text ;
                        break;
               case   "text" :
                        break;
               case    "textarea" :
                        break;
               case   "checkbox" :
               case    "radio" :
                        break;
               case    "select" :
                        break;
               case    "attachment" :
                  $upload_file = $HTTP_POST_FILES[ $form_mail[ $i ]["name"] ][ "tmp_name" ] ;
                        if( ! is_uploaded_file($upload_file)  )
                           return  ERR_SELECT_UPLOAD . $text; 
                        break;
               case strtolower("Time(HH:MM:SS)"):
                        break;
               case strtolower("Time(HH:MM)"):
                        break;
               default :

            }
      endif;
   }
   
   return "" ;
}

function formSelected( $var, $val ) 
{ 
    echo ( $var == $val ) ? "selected" : ""; 
} 

function formChecked( $var, $val ) 
{ 
    echo ( $var == $val ) ? "checked" : ""; 
} 

function formIsEMail( $email ){ 
        return ereg( "^(.+)@(.+)\\.(.+)$", $email ); 
} 

function selectList( $name, $selectedValue, $start, $end, $prompt = "-Select-", $style = "" ) 
{ 
    $tab = "\t" ; 
    print "<select name=\"$name\" $style>\n" ; 
    print $tab . "<option value=''>$prompt</option>\n" ; 
    $nLen = strlen( "$end" ) ; 
    $prefix_zero = str_repeat( "0", $nLen ); 
    for( $i = $start; $i <= $end ; $i ++ ){ 
        $stri = substr( $prefix_zero . $i, strlen($prefix_zero . $i)-$nLen, $nLen ); 
        $selected = ( $stri == $selectedValue ) ? " selected " : "" ; 
        print $tab . "<option value=\"$stri\" $selected >$stri</option>\n" ; 
    } 
    print "</select>\n\n" ; 
} 

function mailAttachments( $to = "" , $subject = "" , $message = "" , $from = "barrym@owt200x.us" , $charset = "iso-8859-1", $cc = "" , $bcc = "" ){ 
    global $HTTP_POST_FILES ; 
     
        if( ! strlen( trim( $to ) ) ) return "Missing \"To\" Field." ; 

        $boundary = "====_OwT_PHP_Contact_Form_" . md5( uniqid( srand( time() ) ) ) . "====";  

        $headers = "From: $from\r\n";  
        if ($cc) $headers .= "CC: $cc\r\n";  
        if ($bcc) $headers .= "BCC: $bcc\r\n";  
      $plainHeaders = $headers ;
        $headers .= "MIME-Version: 1.0\nContent-type: multipart/mixed;\n\tboundary=\"$boundary\"\n";  

        $txtMsg = "\nThis is a multi-part message in MIME format.\n" .  
                        "\n--$boundary\n" . 
                        "Content-Type: text/plain;\n\tcharset=\"$charset\"\n\n"  . $message . "\n"; 
         
        $sError = "" ; 
        $nFound = 0; 
        foreach( $HTTP_POST_FILES as $aFile ){ 
                    $sFileName = $aFile[ "tmp_name" ] ; 
                    $sFileRealName = $aFile[ "name" ] ; 
                    if( is_file( $sFileName ) ): 
                         
                        if( $fp = fopen( $sFileName, "rb" ) ) : 
                            $sContent = fread( $fp, filesize( $sFileName ) ); 
                            $sFName = basename( $sFileRealName ) ; 
                            $sMIME = getMIMEType( $sFName ) ; 
                             
                            $bPlainText = ( $sMIME == "text/plain" ) ; 
                            if( $bPlainText ) : 
                                $encoding = "" ; 
                            else: 
                                $encoding = "Content-Transfer-Encoding: base64\n";  
                                $sContent = chunk_split( base64_encode( $sContent ) );  
                            endif; 
                             
                            $sEncodeBody .=     "\n--$boundary\n" .  
                                                        "Content-Type: $sMIME;\n" .  
                                                        "\tname=\"$sFName\"\n" . 
                                                        $encoding .  
                                                        "Content-Disposition: attachment;\n" .  
                                                        "\tfilename=\"$sFName\"\n\n" . 
                                                        $sContent . "\n" ; 
                            $nFound ++;                                                 
                        else: 
                            $sError .= "<br>File $sFileName can not open.\n" ; 
                        endif;
                         
                    else: 
                        $sError .= "<br>File $sFileName doesn't exist.\n" ; 
                    endif;
        };
   
         $sEncodeBody .= "\n\n--$boundary--" ; 
         $sSource = $txtMsg . $sEncodeBody ; 


       $nFound ? mail( $to, $subject, $sSource, $headers  )
                      : mail( $to, $subject, $message, $plainHeaders );  

        return $sError ;         
} 

function getMIMEType( $sFileName = "" ) { 
         
        $sFileName = strtolower( trim( $sFileName ) ); 
        if( ! strlen( $sFileName  ) ) return ""; 
         
        $aMimeType = array(  
                                        "txt" => "text/plain" , 
                                        "pdf" => "application/pdf" , 
                                        "zip" => "application/x-compressed" , 

                                        "html" => "text/html" , 
                                        "htm" => "text/html" , 

                                        "avi" => "video/avi" , 
                                        "mpg" => "video/mpeg " , 
                                        "wav" => "audio/wav" , 

                                        "jpg" => "image/jpeg " , 
                                        "gif" => "image/gif" , 
                                        "tif" => "image/tiff " , 
                                        "png" => "image/x-png" , 
                                        "bmp" => "image/bmp"  
                                    ); 
        $aFile = split( "\.", basename( $sFileName ) ) ; 
        $nDiminson = count( $aFile ) ; 
         $sExt = $aFile[ $nDiminson - 1 ] ;
         
        return ( $nDiminson > 1 ) ? $aMimeType[ $sExt ] : "";  
} 

function appendToFile( $sFileName = "", $line = "" ){ 
    if( !$sFileName || !$line ) return 0; 
    $hFile = fopen( "$sFileName", "a+w" ); 
    $nBytes = 0; 
    if( $hFile ){ 
        $nBytes = fputs( $hFile , trim($line)."\r\n" ); 
        fclose( $hFile ); 
    }; 
    return $nBytes ; 
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<link rel="stylesheet" type="text/css"
href="portfolio.css" >
<link rel="stylesheet" type="text/css"
href="css4.css" >
<link rel="stylesheet" type="text/css"
href="contact.css" >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<title>Contact</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" >
<style type="text/css">
<!--
.style30 {color: #FFFFFF}
-->
</style>

<script type="text/javascript" src="contact.js"></script>
<!--[if IE]>
<style type="text/css" media="screen">
#menu ul li {float: left; width: 100%;}
</style>
<![endif]-->
<!--[if lt IE 7]>
<style type="text/css" media="screen">
body {
behavior: url(csshover.htc);
font-size: 100%;
}
#menu ul li {float: left; width: 100%;}
#menu ul li a {height: 1%;}
</style>
<![endif]-->
</head>

<body id="contact">
<div class="header"></div>
<div class="logo"><img src="logo.jpg" alt="Logo" width="200" height="100" ></div>
<div class="bar1"><img src="header.jpg" alt="header" width="799" height="100"></div>
<div class="left_column" style="text-align:center">
        <div id="menu">
         <ul id="navlist">
   <li><a href="index.html" title="Link to Homepage">Home</a>
      <ul>
         <li><a href="about.html" title="Link to About Page" >About</a></li>
         <li><a href="portfolio.html" title="Link to Portfolio Page">Portfolio</a>
            <ul>
               <li><a href="fashion.html" title="Link to Fashion Page">Fashion</a></li>
               <li><a href="portrait.html" title="Link to Portrait Page">Portrait</a></li>
               <li><a href="reportage.html" title="Link to Reoportage Page">Reportage</a></li>
               <li><a href="travel.html" title="Link to Travel Page" >Travel</a></li>
            </ul>
         </li>
         <li><a href="contact1.php" title="Link to contact page" id="connav">Contact</a></li>
      </ul>
   </li>
</ul>

            </div>
      </div>
<div class="about">
<form onClick="highlight(event)" name="<?php echo $formname; ?>" action="<?php print PHP_SELF ?>" method='post' enctype='multipart/form-data'>
<fieldset>
<legend>Contact Details</legend>

<input type='hidden' name='formmail_submit' value='Y'>
<input type='hidden' name='esh_formmail_recipient' value="<?php echo $safename; echo $atsymbol; echo $safedomain; ?>">
<input type='hidden' name='esh_formmail_cc' value="<?php echo $safeccname; echo $ccemailat; echo $safeccdomain; ?>">
<input type='hidden' name='esh_formmail_return_subject' value="<?php echo $autorespondsubject; ?>">
<input type='hidden' name='esh_formmail_return_msg' value="<?php echo $autorespondmessage; ?>">
<input type='hidden' name='esh_formmail_charset' value="">
<center><img src="required.gif" alt="required" width="12" height="12"> <font color="#FFFFFF">Denotes Required Field<br></font></center>

<?php
   if( !$isHideForm ): 
      global $sErr ;
      if( $sErr ) print "<a name='error'></a><center><font class='form_error' >$sErr</font></center>"; 

      $starColor = $sErr ? "#ff0000" : "#000000";
      $style=" class='form_text' ";

?>
<ul>
<li>
<label for="Name" class="style30">Name: <img src="required.gif" alt="required" width="12" height="12"></label>
<input name="Name" onBlur="stripHTML(<?php echo $formname; ?>.Name)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "Name" ] ); ?>">
</li>
<li>
<label for="esh_formmail_subject" class="style30">Subject: <img src="required.gif" alt="required" width="12" height="12"></label>
<input name="esh_formmail_subject" id="esh_formmail_subject" onBlur="stripHTML(<?php echo $formname; ?>.esh_formmail_subject)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "esh_formmail_subject" ] ); ?>" >
</li>
<li>
<label for="Email_Address" class="style30">Email Address: <img src="required.gif" alt="required" width="12" height="12"></label>
<input name="Email_Address" id="Email_Address" onBlur="stripHTML(<?php echo $formname; ?>.Email_Address)" type="text" size="25" maxlength="50" value="<?php print HtmlSpecialChars( $_POST[ "Email_Address" ] ); ?>" >
</li>
<li>
<label for="Daytime_Telephone" class="style30">Daytime Phone Number: <img src="required.gif" alt="required" width="12" height="12"></label>
<input name="Daytime_Telephone" id="Daytime_Telephone" onBlur="stripHTML(<?php echo $formname; ?>.Daytime_Telephone)" type="text" size="25" maxlength="12" value="<?php print HtmlSpecialChars( $_POST[ "Daytime_Telephone" ] ); ?>" >
</li>
<li>
<label for="Evening_Telephone" class="style30">Evening Phone Number: <img src="required.gif" alt="required" width="12" height="12"></label>
<input name="Evening_Telephone" id="Evening_Telephone" onBlur="stripHTML(<?php echo $formname; ?>.Evening_Telephone)" type="text" size="25" maxlength="12" value="<?php print HtmlSpecialChars( $_POST[ "Evening_Telephone" ] ); ?>" >
</li>
<li>
<label for="Reach_Me_By" class="style30">Best way to reach you: <img src="required.gif" alt="required" width="12" height="12"></label>
<select name="Reach_Me_By" id="Reach_Me_By">
  <option value="Email" selected="Selected" <?php  formSelected( $_POST[ "Reach_Me_By" ], "Email" ); ?>>E-mail</option>
  <option value="Daytime Telephone" <?php  formSelected( $_POST[ "Reach_Me_By" ], "Daytime Telephone" ); ?>>Daytime Telephone</option>
  <option value="Evening Telephone" <?php  formSelected( $_POST[ "Reach_Me_By" ], "Evening Telephone" ); ?>>Evening Telephone</option>
</select>
</li>
<li>
<label for="How_I_Found_You"><span class="style30">How did you find me: <img src="required.gif" alt="required" width="12" height="12"></span></label>
<input name="How_I_Found_You" id="How_I_Found_You" onBlur="stripHTML(<?php echo $formname; ?>.How_I_Found_You)" type="text" size="25" maxlength="50" value="<?php print HtmlSpecialChars( $_POST[ "How_I_Found_You" ] ); ?>" >
</li>
<li>
<label for="Type_of_Event" class="style30">Type of event:</label>
<input name="Type_of_Event" id="Type_of_Event" onBlur="stripHTML(<?php echo $formname; ?>.Type_of_Event)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "Type_of_Event" ] ); ?>" >
</li>
<li>
<label for="Date_of_Event" class="style30">Date of event:</label>
<input name="Date_of_Event" id="Date_of_Event" OnClick="javascript:showCal('Calendar')" onBlur="stripHTML(<?php echo $formname; ?>.Date_of_Event)" type="text" size="25" maxlength="20" value="<?php print HtmlSpecialChars( $_POST[ "Date_of_Event" ] ); ?>" >
</li>
<li>
<label for="Budget" class="style30">Budget:</label>
<select name="Budget" id="Budget">
  <option value="£100 - £300" selected="Selected" <?php  formSelected( $_POST[ "Budget" ], "£100 - £300" ); ?>>£100 - £300</option>
  <option value="£300 - £500" <?php  formSelected( $_POST[ "Budget" ], "£300 - £500" ); ?>>£300 - £500</option>
  <option value="£500 - £700" <?php  formSelected( $_POST[ "Budget" ], "£500 - £700" ); ?>>£500 - £700</option>
  <option value="£700 - £900" <?php  formSelected( $_POST[ "Budget" ], "£700 - £900" ); ?>>£700 - £900</option>
  <option value="£900 - £1100" <?php  formSelected( $_POST[ "Budget" ], "£900 - £1100" ); ?>>£900 - £1100</option>
  <option value="£1100+" <?php  formSelected( $_POST[ "Budget" ], "£1100+" ); ?>>£1100+</option>
</select>
</li>
<li>
<label for="Comments_or_Questions"><span class="style30">Comments or Questions:</span>ns:</label>
<textarea name="Comments_or_Questions" id="Comments_or_Questions" onBlur="stripHTML(<?php echo $formname; ?>.Comments_or_Questions)" cols="25" rows="3"><?php print HtmlSpecialChars( $_POST[ "Comments_or_Questions" ] ); ?></textarea>
</li>
<li>
    <div align="center">

      <input type="submit" name="Submit" value="Submit" >
      </div>
    </li>
</ul>
</fieldset>
</form>
<?php

      if( $sErr ) print "<script language='javascript' type='text/javascript'>location.href='#error';</script>";;; 

         else:
            print( "<br><br><center><b>$thankyoumessage</b></center>" );
         endif;


?>

</div>
<div class="quotes"></div>
<div class="bar"></div>
<div class="flash"><object data="banner1.swf" type="application/x-shockwave-flash" width="999" height="100">
<param name="MOVIE" value="banner1.swf">
</object></div>
<div class="footer">
  <div align="right"></div>
</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/139000-validating-php-page/#findComment-727140
Share on other sites

it was a PHP function defined in that big block of PHP code we just added. it just prints out some stuff

 

a FOR tag on a LABEL refers to the ID of an element in HTML. like so:

<label for="email">Email Address:</label>
<input type="text" name="email" id="email" />

Link to comment
https://forums.phpfreaks.com/topic/139000-validating-php-page/#findComment-727158
Share on other sites

oh ok, so was the php script not in the original post?  Sorry to ask so many questions but i want to actually learn instead of being food sped it.

 

Yeah i had a look at the id's and it was just that it had one warning on the validator for name and i compared it with the rest and then gave it an id.

 

Your page is now  up and it's all validated so thanks!

 

There are a few more things, (if it's not too much trouble, if it is then thanks for all the help thus far.) How can i get rid of the email addresses when you view the page source?

 

This is what it shows you and i don't want it to say the email addresses and the auto responder message in the page source.

 

<input type='hidden' name='formmail_submit' value='Y'>

<input type='hidden' name='esh_formmail_recipient' value="contact@jasongold.org">

<input type='hidden' name='esh_formmail_cc' value="admin@jaosngold.org">

<input type='hidden' name='esh_formmail_return_subject' value="Thank you for contacting us">

<input type='hidden' name='esh_formmail_return_msg' value="Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please visit our website at www.jasongold.org">

<input type='hidden' name='esh_formmail_charset' value="">

<center><img src="required.gif" alt="required" width="12" height="12"> <font color="#FFFFFF">Denotes Required Field<br></font></center>

 

And the last thing is, i want to have more then two email addresses i can send the form to but the only place i've been told i can put the email address is here

 

//Email Name
$emailname = "contact"; // DO NOT PUT THE @, It includes itself

//Email Domain
$emaildomain = "jasongold.org"; // PUT THE .COM or Other

//Carbon Copy Email Name - Leave blank to disable
$ccemailname = "admin"; // DO NOT PUT THE @ after email name, It includes itself leave blank to disable.

//Carbon Copy Email Domain - Leave blank to disable
$ccemaildomain = "jasongold.org"; // PUT THE .COM or Other. Leave blank to disable.

Which only allows two email addresses which surely must be wrong as you must be allowed more then two?

Link to comment
https://forums.phpfreaks.com/topic/139000-validating-php-page/#findComment-727166
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.