Hi,
I have a form that has been running for 3 to 4 years without any problems. All of a sudden last week it stopped working. (another on the site stopped working aswell)
It's on a shared hosting platform, so my only guess is that the PHP settings or a server setting has been changed by my wonderful hosting company.
I've asked the question but so far have had no response.
In the meantime I'm hoping someone on here may be able to help.
You can see the php settings by going here:
The code for the script is as follows...
Thanks for any help anyone can offer. Hopefully someone will be able to get this script working again.
Many thanks
Ben
I have a form that has been running for 3 to 4 years without any problems. All of a sudden last week it stopped working. (another on the site stopped working aswell)
It's on a shared hosting platform, so my only guess is that the PHP settings or a server setting has been changed by my wonderful hosting company.
I've asked the question but so far have had no response.
In the meantime I'm hoping someone on here may be able to help.
You can see the php settings by going here:
The code for the script is as follows...
Code:
<?
session_start(); // Start Session
header("Cache-control: private");
/* checks to see if session is already registered if registered no need to register session */
if(!session_is_registered('first')){
session_register('first');
$_SESSION['first'] = "true";
session_register('topic');
$_SESSION['topic'] = $_GET["topic"];
session_register('id');
$_SESSION['id'] = $_GET["id"];
if($_SESSION['topic'] == ''){
session_register('topic');
$_SESSION['topic'] = "General Enquiry";
}
}
if ( $_POST["check"] == 'send') {
$name = trim(stripslashes($_POST['name']));
$lastname = trim(stripslashes($_POST['lastname']));
$laim1 = trim(stripslashes($_POST['laim1']));
$laim2 = trim(stripslashes($_POST['laim2']));
$company = trim(stripslashes($_POST['company']));
$let = trim(stripslashes($_POST['let']));
$town = trim(stripslashes($_POST['town']));
$location = trim(stripslashes($_POST['location']));
$comments = trim(stripslashes($_POST['comments']));
$mail = trim(stripslashes($_POST['mail']));
if ($_SESSION['id'] == '1'){
include 'includes/description1.php';
}
if ($_SESSION['id'] == '2'){
include 'includes/description2.php';
}
if ($_SESSION['id'] == '3'){
include 'includes/description3.php';
}
if ($_SESSION['id'] == '4'){
include 'includes/description4.php';
}
if ($_SESSION['id'] == '5'){
include 'includes/description5.php';
}
if ($_SESSION['id'] == '6'){
include 'includes/description6.php';
}
if ($_SESSION['id'] == '7'){
include 'includes/description7.php';
}
/// define NVQ DESCRIPTION
$no = array( 'Cornwall' , 'Cumbria' , 'Durham' , 'East Riding of Yorkshire' , 'EastEssex' , 'Essex' , 'Herefordshire' , 'Hertfordshire' , 'Humberside' , 'Isle of Wight' , 'Isles of Scilly' , 'Kent' , 'Middlesex' , 'Norfolk' , 'Northern Ireland' , 'North Yorkshire' , 'Northumberland' , 'Rutland' , 'Scotland' , 'Shropshire' , 'South Yorkshire' , 'Suffolk' , 'Tyne and Wear' , 'Wales' , 'Westmorland' , 'West Yorkshire' , 'Yorkshire') ;
//define automated NO TRAINING email
///////////////////////////////////////////// CHECK EMAIL ADDRESS /////////////////////////////////////////////
function check_email_address($laim1) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $laim1)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $laim1);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}
///////////////////////////////////////////// CHECK PHONE //////////////////////////////////////////////////////////
function isPhoneValid($let) {
if (!ereg('^[0-9 ]{7,21}$', $let)){
return false;
}
return true;
}
if (!isPhoneValid($let)) { $errorPhone = 'true'; $validation1 = 'error';}else{ $errorPhone = 'false'; $validation1 = 'false';}
if (!check_email_address($laim1)) { $errorValid = 'true'; $validation2 = 'error';}else{ $errorValid = 'false'; $validation2 = 'false';}
///////////////////////////////////////////// CHECK Nothing is missing //////////////////////////////////////////////////////////
if (!$name) { $errorName = 'true'; $validation = 'error';}
if (!$lastname) { $errorLName = 'true'; $validation = 'error';}
if (!$let) { $errorTel = 'true'; $validation = 'error';}
if (!$laim1) { $errorEmail = 'true'; $validation = 'error';}
if (!$comments) { $errorComments = 'true'; $validation = 'error';}
if (!$company) { $errorCompany = 'true'; $validation = 'error';}
if (!$town) { $errorTown = 'true'; $validation = 'error';}
if (!$location) { $errorlocation = 'true'; $validation = 'error';}
if ($laim1 == $laim2) { $errorMatch = 'false'; }else{ $errorMatch = 'true'; $validation = 'error';}
if ((!$validation == 'error') && ($validation1 == 'false') && ($validation2 == 'false')){
//// force format below - first to all lowercase - then to capital 4 first letter of every word ////////////////////////////////////////////
$Format1Name = strtolower ($name);
$Format1Name = ucwords ($Format1Name);
$Format2Name = strtolower ($lastname);
$Format2Name = ucwords ($Format2Name);
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
$email ="$laim1";
$subject="RE: Training Centre";
//NOT AVAIABLE AUTOMATED EMAILS /////////////////////////////////////////////////////////////////////////////
if (in_array($location,$no)) {
if (($_SESSION['topic'] == 'HSC Level 2') or ($_SESSION['topic'] == 'HSC Level 3') or ($_SESSION['topic'] == 'HSC Level 4') or ($_SESSION['topic'] == 'Registered Managers') or ($_SESSION['topic'] == 'Management Level 4') or ($_SESSION['topic'] == 'A1 Assessor') or ($_SESSION['topic'] == 'V1 Internal Verifier')){
$emailoffice="info@domain.co.uk";
$mailContent="Dear $Format1Name,
At the moment we are unable to offer the $topic award in your area.
Below are some websites that may assist you in finding availability for the $topic award in your area
[URL unfurl="true"]http://careersadvice.direct.gov.uk/[/URL]
[URL unfurl="true"]http://www.hotcourses.com[/URL]
If you have any questions or, require further information, please contact us.
Kind regards";
}
if (($_SESSION['topic'] == 'Food Hygiene') or ($_SESSION['topic'] == 'Fire Safety') or ($_SESSION['topic'] == 'First Aid') or ($_SESSION['topic'] == 'Health and Safety') or ($_SESSION['topic'] == 'Moving and Handling') or ($_SESSION['topic'] == 'Palliative Care ')){
$emailoffice="info@domain.co.uk";
$mailContent="Dear $Format1Name,
At the moment we are unable to offer this training course in your area.
Kind regards";
}
}else{
if (($topic == 'HSC Level 2') or ($topic == 'HSC Level 3') or ($topic == 'HSC Level 4') or ($topic == 'Registered Managers') or ($topic == 'Management Level 4') or ($topic == 'A1 Assessor') or ($topic == 'V1 Internal Verifier')){
$emailoffice="info@domain.co.uk";
$mailContent="Dear $Format1Name,
Thank you for contacting us
Please find information below about this award.
$description
We look forward to hearing from you.
Kind regards
";
}
if (($_SESSION['topic'] == 'Food Hygiene') or ($_SESSION['topic'] == 'Fire Safety') or ($_SESSION['topic'] == 'First Aid') or ($_SESSION['topic'] == 'Health and Safety') or ($_SESSION['topic'] == 'Moving and Handling') or ($_SESSION['topic'] == 'Palliative Care ')){
$emailoffice="info@domain.co.uk";
$mailContent="Dear $Format1Name,
Thank you for contacting us
We have received your online form and one of our training advisors will contact you shortly
Kind regards
";
}
}
if (($_SESSION['topic'] == 'General Enquiry') or ($_SESSION['topic'] == 'Balancing the Personal and Professional') or ($_SESSION['topic'] == 'Protection of Vulnerable Adults') or ($_SESSION['topic'] == 'Dementia Inhouse Training') or ($_SESSION['topic'] == 'Challenging Behaviour')){
$emailoffice="info@domain.co.uk";
$mailContent="Dear $Format1Name,
Thank you for contacting us.
We have received your online form. One of our training advisors will contact you shortly.
Kind regards
";
}
$from="info@domain.co.uk";
mail($email, $subject, $mailContent,"From: $from\nX-Mailer: PHP/" . phpversion());
//////////////////////////////////////////////////////// email office ////////////////////////////////////////////
$subjectoffice="Enquiry From Website";
$mailContentOffice="
SUBJECT: $topic\n
Name: $Format1Name $Format2Name
Email: $laim1
Company or Employer: $company
Telephone: $let
Town: $town
County: $location
Details of enquiry: $comments
Newsletter: $mail\n
NOTE:
The following has been sent to $Format1Name $Format2Name AUTOMATICALLY FROM THE WEBSITE:\n
$mailContent";
mail($emailoffice, $subjectoffice, $mailContentOffice,"From: $laim1\nX-Mailer: PHP/" . phpversion());
$_SESSION = array();
session_destroy();
$clear = "ok";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html>
<head>
<title>Contact Us</title>
<meta name="description" content="Training Centre ">
<meta name="keywords" content="nvq training">
<meta name="robots" content="index, follow">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="wp2008.css" rel="stylesheet" type="text/css">
<!--[if IE]><link rel="stylesheet" type="text/css" href="ie.css" /><![endif]-->
</head>
<body >
<div id="container">
<div id="header">
<? include 'includes/inc_title.html';?>
<div id="headcont"><img src="img/wp_headtag1.gif" alt="A specialist centre providing training " />
<p><? echo date("l j F Y")?></p>
</div>
</div>
<div id="nav">
<div id="pageNavbar">
<? include 'includes/inc_topnav.html';?>
</div>
</div>
<div id="wrapper">
<div id="content">
<?
if (!$_POST['check']){
echo "<p>If you would like to contact us please fill in the online form. Our Training advisors will be happy to help
you.</p>";
}
///////////////////////////////////////////// Display any errors //////////////////////////////////////////////////////////
if ($validation == 'error'){
echo"<p style='color:red;'><strong>Sorry we could not process your form.</strong><br />";
//-------------------------------------------------------------------------------------------------Error checking
if ($errorName == 'true') {
echo "Please enter your first name.<br />";
}
if ($errorLName == 'true') {
echo "Please enter your last name.<br />";
}
if ($errorEmail == 'true') {
echo "Please enter your email address.<br />";
}
if ($errorMatch == 'true') {
echo "The email addresses you have entered do not match. Please try again.<br />";
}
if ($errorCompany == 'true') {
echo "Please enter your Company or Employer Name.<br />";
}
if ($errorTel == 'true') {
echo "Please enter your Telephone number.<br />";
}
if ($errorTown == 'true') {
echo "Please enter your Town.<br />";
}
if ($errorlocation == 'true') {
echo "Please select a County.<br />";
}
if ($errorComments == 'true') {
echo "Please give details of your enquiry.<br />";
}
}
if ((($validation1 == 'error') || ($validation2 == 'error')) && (!$validation == 'error')){
echo"<p style='color:red;'><strong>Sorry we could not process your form.</strong><br />";
if ($errorPhone == 'true') {
echo "You have entered an invalid telephone number. Please try again.<br />";
}else{echo"";}
if ($errorValid == 'true') {
echo "Please enter a valid email address.<br />";
}else{echo"";}
}
if ($clear == 'ok'){
echo "<p><strong>Thank you</strong><br />Your enquiry form has been successfully sent.<br /><br />We will contact you shortly.<br />";
}
?></p>
<? if (!$clear == 'ok'){ ?>
<form class="contact" action="<?php echo $PHP_SELF; ?>" method="post" onSubmit="return check(this)">
<table width="100%" border="0" align="center" cellpadding="4" cellspacing="2" class="contact">
<tr>
<td class="contact" height="44"> First Name: <font color="#FF0000">*</font> </td>
<td><input name="name" type="text" class="FormField" value="<? echo $name; ?>" /></td>
</tr>
<tr>
<td class="contact" height="44"> Last Name: <font color="#FF0000">*</font> </td>
<td> <input name="lastname" type="text" class="FormField" value="<? echo $lastname; ?>" /></td>
</tr>
<tr>
<td class="contact" height="44"> Email Address: <font color="#FF0000">*</font> </td>
<td><input name="laim1" type="text" class="FormField" value="<? echo $laim1; ?>" />
</td>
</tr>
<tr>
<td class="contact" height="44"> Confirm Email Address: <font color="#FF0000">*</font> </td>
<td><input name="laim2" type="text" class="FormField" value="<? echo $laim2; ?>" />
</td>
</tr>
<tr>
<td height="39" class="contact"> Company / Employer Name:<font color="#FF0000">*</font>
</td>
<td> <input name="company" type="text" class="FormField" value="<? echo $company; ?>" >
</td>
</tr>
<tr>
<td height="39" class="contact"> Telephone:<font color="#FF0000">*</font></td>
<td><input name="let" type="text" class="FormField" value="<? echo $let; ?>" maxlength="21" />
</td>
</tr>
<tr>
<td height="39" class="contact"> Town:<font color="#FF0000">*</font> </td>
<td><input name="town" type="text" class="FormField" value="<? echo $town; ?>">
</td>
</tr>
<tr>
<td height="37" class="contact">County:<font color="#FF0000">*</font> </td>
<td> <select name="location" class="FormField">
<option value="" <?=$location == "" ? "selected" : "" ?> selected>Select
your location
<option value="nonuk" <?=$location == "nonuk" ? "selected" : "" ?> >Non
UK
<option value="Avon" <?=$location == "Avon" ? "selected" : "" ?> >Avon
<option value="Bedfordshire" <?=$location == "Bedfordshire" ? "selected" : "" ?> >Bedfordshire
<option value="Berkshire" <?=$location == "Berkshire" ? "selected" : "" ?> >Berkshire
<option value="Buckinghamshire" <?=$location == "Buckinghamshire" ? "selected" : "" ?> >Buckinghamshire
<option value="Bristol" <?=$location == "Bristol" ? "selected" : "" ?> >Bristol
<option value="Cambridgeshire" <?=$location == "Cambridgeshire" ? "selected" : "" ?> >Cambridgeshire
<option value="Cheshire" <?=$location == "Cheshire" ? "selected" : "" ?> >Cheshire
<option value="Cornwall" <?=$location == "Cornwall" ? "selected" : "" ?> >Cornwall
<option value="Cumbria" <?=$location == "Cumbria" ? "selected" : "" ?> >Cumbria
<option value="Derbyshire" <?=$location == "Derbyshire" ? "selected" : "" ?> >Derbyshire
<option value="Devon" <?=$location == "Devon" ? "selected" : "" ?> >Devon
<option value="Dorset" <?=$location == "Dorset" ? "selected" : "" ?> >Dorset
<option value="Durham" <?=$location == "Durham" ? "selected" : "" ?> >Durham
<option value="East Riding of Yorkshire" <?=$location == "East Riding of Yorkshire" ? "selected" : "" ?> >East
Riding of Yorkshire
<option value="EastEssex" <?=$location == "EastEssex" ? "selected" : "" ?> >East
Essex
<option value="Essex" <?=$location == "Essex" ? "selected" : "" ?> >Essex
<option value="Gloucestershire" <?=$location == "Gloucestershire" ? "selected" : "" ?> >Gloucestershire
<option value="Greater Manchester" <?=$location == "Greater Manchester" ? "selected" : "" ?> >Greater
Manchester
<option value="Hampshire" <?=$location == "Hampshire" ? "selected" : "" ?> >Hampshire
<option value="Herefordshire" <?=$location == "Herefordshire" ? "selected" : "" ?> >Herefordshire
<option value="Hertfordshire" <?=$location == "Hertfordshire" ? "selected" : "" ?> >Hertfordshire
<option value="Huntingdonshire" <?=$location == "Huntingdonshire" ? "selected" : "" ?> >Huntingdonshire
<option value="Humberside" <?=$location == "Humberside" ? "selected" : "" ?> >Humberside
<option value="Isle of Wight" <?=$location == "Isle of Wight" ? "selected" : "" ?> >Isle
of Wight
<option value="Isles of Scilly" <?=$location == "Isles of Scilly" ? "selected" : "" ?> >Isles
of Scilly
<option value="Kent" <?=$location == "Kent" ? "selected" : "" ?> >Kent
<option value="Lancashire" <?=$location == "Lancashire" ? "selected" : "" ?> >Lancashire
<option value="Leicestershire" <?=$location == "Leicestershire " ? "selected" : "" ?> >Leicestershire
<option value="Lincolnshire" <?=$location == "Lincolnshire" ? "selected" : "" ?> >Lincolnshire
<option value="London" <?=$location == "London" ? "selected" : "" ?> >London
<option value="Merseyside" <?=$location == "Merseyside" ? "selected" : "" ?> >Merseyside
<option value="Middlesex" <?=$location == "Middlesex" ? "selected" : "" ?> >Middlesex
<option value="Norfolk" <?=$location == "Norfolk" ? "selected" : "" ?> >Norfolk
<option value="Northern Ireland" <?=$location == "Northern Ireland" ? "selected" : "" ?> >Northern
Ireland
<option value="North Yorkshire" <?=$location == "North Yorkshire" ? "selected" : "" ?> >North
Yorkshire
<option value="Northamptonshire" <?=$location == "Northamptonshire" ? "selected" : "" ?> >Northamptonshire
<option value="Northumberland" <?=$location == "Northumberland" ? "selected" : "" ?> >Northumberland
<option value="Nottinghamshire" <?=$location == "Nottinghamshire" ? "selected" : "" ?> >Nottinghamshire
<option value="Oxfordshire" <?=$location == "Oxfordshire" ? "selected" : "" ?> >Oxfordshire
<option value="Rutland" <?=$location == "Rutland" ? "selected" : "" ?> >Rutland
<option value="Scotland" <?=$location == "Scotland" ? "selected" : "" ?> >Scotland
<option value="Shropshire" <?=$location == "Shropshire" ? "selected" : "" ?> >Shropshire
<option value="Somerset" <?=$location == "Somerset" ? "selected" : "" ?> >Somerset
<option value="South Yorkshire" <?=$location == "South Yorkshire" ? "selected" : "" ?> >South
Yorkshire
<option value="Staffordshire " <?=$location == "Staffordshire" ? "selected" : "" ?> >Staffordshire
<option value="Suffolk" <?=$location == "Suffolk" ? "selected" : "" ?> >Suffolk
<option value="Surrey" <?=$location == "Surrey" ? "selected" : "" ?> >Surrey
<option value="Sussex" <?=$location == "Sussex" ? "Sussex" : "" ?> >Sussex
<option value="Tyne and Wear" <?=$location == "Tyne and Wear" ? "Tyne and Wear" : "" ?> >Tyne
and Wear
<option value="Wales" <?=$location == "Wales" ? "selected" : "" ?> >Wales
<option value="Warwickshire" <?=$location == "Warwickshire" ? "selected" : "" ?> >Warwickshire
<option value="Westmorland" <?=$location == "Westmorland " ? "selected" : "" ?> >Westmorland
<option value="West Midlands" <?=$location == "West Midlands " ? "selected" : "" ?> >West
Midlands
<option value="West Sussex" <?=$location == "West Sussex " ? "selected" : "" ?> >West
Sussex
<option value="West Yorkshire" <?=$location == "West Yorkshire " ? "selected" : "" ?> >West
Yorkshire
<option value="Wiltshire" <?=$location == "Wiltshire" ? "selected" : "" ?> >Wiltshire
<option value="Worcestershire" <?=$location == "Worcestershire" ? "selected" : "" ?> >Worcestershire
<option value="Yorkshire" <?=$location == "Yorkshire" ? "selected" : "" ?> >Yorkshire
</select> </td>
</tr>
<tr>
<td height="84" class="contact"> Detail of enquiry: <font color="#FF0000">*</font> </td>
<td> <textarea name="comments" rows="3" class="FormField" id="textarea"><? echo $comments; ?></textarea>
</td>
</tr>
<tr>
<td height="20" class="contact"><input name="mail" type="checkbox" style="border:0px;" value="yes" CHECKED>
Receive FREE Care Newsletter</td>
<td></td>
</tr>
<tr>
<td height="31" class="contact"> <input type="submit" name="add" value="Submit">
<input type="hidden" name="check" value="send" /> </td>
<td></td>
</tr>
</table>
</form>
<? } ?>
<br /><br />
</div>
</div>
<div id="left"><img src="img/label_trainingnew.gif" alt="Health and social care NVQ Awards" width="212" height="21" /><div class="categories">
<? include 'includes/inc_leftnavstandard.html';?>
</div>
<a href="health_social_care_training.php"><img src="img/butanalysis.gif" alt="Do you have Care staff training needs that impact on your business development?" border="0" style="margin-top:1.8em" /></a>
<a href="newsletter.php"><img src="img/butnewsletter.gif" alt="FREE Newsletter Subcribe here!" name="newbut" width="207" height="24" border="0" id="newbut" style="margin-bottom:9px; margin-top:2em;" /></a> <a href="health_social_care.php"><img src="img/butbrochure.gif" alt="Download Brochure" width="207" height="25" border="0" style="margin-bottom:9px;" /></a>
<a href="nvq_health_social_care.php" ><img style="margin-bottom:9px;" alt="Email this page to your friend!" src="img/butfriend.gif" border="0" width="207" height="25" /></a>
<? include 'includes/inc_social.html';?>
<? include 'includes/inc_credit.html';?>
</div>
<div id="right"><a href="health_social_care_recruitment.php"><img src="img/butrecruit.jpg" alt="W&P Health and Social Care Training Centre are looking for Assessors, IV's and Trainers" border="0" style="margin-left:10px; margin-bottom:30px;" /></a>
<div class="contactbox">
<? include 'includes/inc_contactinfo.html';?>
</div>
</div>
<? include 'includes/inc_footer.html';?>
</div>
</body>
</html>
Thanks for any help anyone can offer. Hopefully someone will be able to get this script working again.
Many thanks
Ben