Hi guys,
I've got 3 pages all of which update successfully, so I know the basics of my code work. I've amended one of them to create a new page, changing the form/sql code and the error checking to incorporate the correct fields.
I'm guessing there's something wrong with the SQL, but I can't see what it is. I'm not getting any error messages or confirmation messages and the table isn't updating.
Could someone please just double check my code and show me the really stupid bit of syntax that I'm missing please?
I thought maybe the ID wasn't passing over, but again, the syntax is pretty much the same as other pages which work!
This is the code which comes after the form, full page text attached.
<?php
}
else
{
require_once('../sypphp/sypcms/DbConnector.php');
$errorlist = array();
$id = $_POST['id'];
$title = $_POST['title'];
$salutation = $_POST['salutation'];
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
$dobday = $_POST['dobday'];
$dobmonth = $_POST['dobmonth'];
$dobyear = $_POST['dobyear'];
$memstatus = $_POST['memstatus'];
$memtype = $_POST['memtype'];
$joinday = $_POST['joinday'];
$joinmonth = $_POST['joinmonth'];
$joinyear = $_POST['joinyear'];
$expday = $_POST['expday'];
$expmonth = $_POST['expmonth'];
$expyear = $_POST['expyear'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$county = $_POST['county'];
$postcode = $_POST['postcode'];
$country = $_POST['country'];
$memnum = $_POST['memnum'];
$email = $_POST['email'];
$oxevents = $_POST['oxevents'];
$scotevents = $_POST['scotevents'];
$allevents = $_POST['allevents'];
$jobsbulletin = $_POST['jobsbulletin'];
$mobtel = $_POST['mobtel'];
$daytel = $_POST['daytel'];
$evetel = $_POST['evetel'];
$company = $_POST['company'];
$position = $_POST['position'];
$department = $_POST['department'];
$companyrep = $_POST['companyrep'];
$college = $_POST['college'];
$course = $_POST['course'];
$collegerep = $_POST['collegerep'];
//validate the fields
if (trim($_POST['firstname']) == '') {$errorlist[] = 'You have not entered a First Name';}
if (trim($_POST['surname']) == '') {$errorlist[] = 'You have not entered a Surname';}
if (trim($_POST['address1']) == '') {$errorlist[] = 'You have not entered an Address/Streetname/number';}
if (trim($_POST['postcode']) == '') {$errorlist[] = 'You have not entered a Postcode';}
if (trim($_POST['memnum']) == '') {$errorlist[] = 'You have not assigned a membership number';}
if (trim($_POST['email']) == '') {$errorlist[] = 'You have not entered an email address';}
if (!checkdate($_POST['dobmonth'], $_POST['dobday'], $_POST['dobyear'])){$errorlist[] = 'Please enter a valid Date of Birth';}
if (!checkdate($_POST['joinmonth'], $_POST['joinday'], $_POST['joinyear'])){$errorlist[] = 'Please enter a valid Join Date';}
if (!checkdate($_POST['expmonth'], $_POST['expday'], $_POST['expyear'])){$errorlist[] = 'Please enter a valid Expiry Date';}
if (sizeof ($errorlist) == 0)
{
$connector = new DbConnector();
$dobtimestamp = array($dobyear, $dobmonth, $dobday);
$postdob = implode("-", $dobtimestamp);
$jointimestamp = array($joinyear, $joinmonth, $joinday);
$postjoin = implode("-", $jointimestamp);
$exptimestamp = array($expyear, $expmonth, $expday);
$postexp = implode("-", $exptimestamp);
$insertQuery="UPDATE members SET title='$title', salutation='$salutation', firstname='$firstname', surname='$surname', dob='$postdob', memstatus='$memstatus', memtype='$memtype', joinday='$joinday', joinmonth='$joinmonth', joindate='$postjoin', expdate='$postexp', address1='$address1', address2='$address2', city='$city', county='$county', postcode='$postcode', country='$country', memnum='$memnum', email='$email', oxevents='$oxevents', scotevents='$scotevents', allevents='$allevents', jobsbulletin='$jobsbulletin', mobtel='$mobtel', daytel='$daytel', evetel='$evetel', company='$company', position='$position', department='$department', companyrep='$companyrep', college='$college', course='$course', collegerep='$collegerep' WHERE id='$id'";
$result = $connector->query($insertQuery) or exit('Error in query: ' . $insertQuery . ' ' . mysql_error());
echo 'Update Successful';
}
else
{
echo 'The following errors have been encountered:<br>';
foreach ($errorlist as $value) {echo $value . '<br>';}
}
}
}
?>