Shiznatix,pimptastic, I tried what you said and I still get the blank screen and no error message telling me which line is at fault, ok guys I dont seem to be getting anywhere and I was determined to get this done. heres my final attempt, i.e the two scripts involved.
Firstly my form script
Code: Select all
<h1>Administration</h1>
<?php
/*** Function: DateSelector**
Input: STRING inName, INTEGER useDate** Output: **
Description: Creates three form fields for get month/day/year*/ function
DateSelector($inName, $useDate)
{ $monthName = array(1=>"January", "February", "March", "April", "May", "June", "July", "August","September", "October", "November", "December");
if($useDate == "")
{
$useDate = time();
}
print("<SELECT NAME=\"" . $inName . "Month\">\n");
for($currentMonth = 1; $currentMonth <= 12; $currentMonth++)
{
echo "<OPTION VALUE=\"";
echo intval($currentMonth);
echo "\"";
if(intval(date("m", $useDate))==$currentMonth)
{
echo " SELECTED";
}
echo ">".$monthName[$currentMonth]."\n";
}
echo "</SELECT>";
echo "<SELECT NAME=".$inName."Day>\n";
for($currentDay=1; $currentDay <= 31; $currentDay++)
{
echo "<OPTION VALUE=\"$currentDay\"";
if(intval(date("d", $useDate))==$currentDay)
{
echo " SELECTED";
}
echo ">$currentDay\n";
}
echo "</SELECT>";
echo "<SELECT NAME=".$inName."Year>\n";
$startYear = date("Y", $useDate);
if($startYear < 1997)
{
$startYear = date("Y");
}
for($currentYear = $startYear-1; $currentYear <= $startYear+2;$currentYear++) {
echo "<OPTION VALUE=\"$currentYear\"";
if(date("Y", $useDate)==$currentYear)
{
echo " SELECTED";
}
echo ">$currentYear\n";
} echo "</SELECT>";}
?>
<?php
/* Connecting, selecting database */
$link = mysql_connect("xxxxx", "xxxx", "xxxxx")
or die("Could not connect : " . mysql_error());
echo "";
mysql_select_db("contact_management_system") or die("Could not select database");
?>
<body onLoad="focus()">
<form method="post" action="processpeople.html">
<table width="100%" border="0">
<tr>
<td width="17%"><font face="Times New Roman, Times, serif"><strong>Salutation</strong></font></td>
<td width="27%"><font face="Times New Roman, Times, serif">
<select name="salutation" style="color: #000000;
background-color: #ADD8E6">
<option>Mr</option>
<option>Mrs</option>
<option>Ms</option>
<option>Miss</option>
<option>Prof</option>
<option>Dr</option>
</select>
</font></td>
<td width="27%"><font face="Times New Roman, Times, serif"><strong>Telephone</strong></font></td>
<td width="29%"><input name="telephone" type="text"style="color: #000000;
background-color: #ADD8E6" size="20" maxlength="20">
</td>
</tr>
<tr>
<td><font face="Times New Roman, Times, serif"><strong>First Name</strong></font></td>
<td><font face="Times New Roman, Times, serif">
<input name="firstname" type="text" size="20"style="color: #000000;
background-color: #ADD8E6">
</font></td>
<td><font face="Times New Roman, Times, serif"><strong>Mobile</strong></font></td>
<td><input name="mobile" type="text"style="color: #000000;
background-color: #ADD8E6" size="20" maxlength="20"></td>
</tr>
<tr>
<td><font face="Times New Roman, Times, serif"><strong>Surname</strong></font></td>
<td><font face="Times New Roman, Times, serif">
<input name="surname" type="text" size="15"style="color: #000000;
background-color: #ADD8E6">
</font></td>
<td><font face="Times New Roman, Times, serif"><strong>Fax</strong></font></td>
<td><font face="Times New Roman, Times, serif">
<input name="fax" type="text"style="color: #000000;
background-color: #ADD8E6" size="20" maxlength="20">
</font></td>
<tr>
<td><font face="Times New Roman, Times, serif"><strong>Organisation</strong></font></td>
<td><font face="Times New Roman, Times, serif">
<input name="organisation" type="text" size="20"style="color: #000000;
background-color: #ADD8E6">
<td><font face="Times New Roman, Times, serif"><strong>E-mail</strong></font></td>
<td><font face="Times New Roman, Times, serif">
<input name="email" type="text"style="color: #000000;
background-color: #ADD8E6" size="25" maxlength="50">
</font></td>
</font></tr>
<tr>
<td><font face="Times New Roman, Times, serif"><strong>Role</strong></font></td>
<td><font face="Times New Roman, Times, serif">
<input name="role" type="text" size="25"style="color: #000000;
background-color: #ADD8E6">
</font></td>
<td><font face="Times New Roman, Times, serif"><strong>Date of Last Contact</strong></font></td>
<td><font face="Times New Roman, Times, serif">
<?php DateSelector("dateoflastcontact_",""); ?>
</font></td>
</tr>
<tr>
<td><font face="Times New Roman, Times, serif"><strong>Address (1)</strong></font></td>
<td><font face="Times New Roman, Times, serif">
<input name="address1" type="text" size="20" style="color: #000000;
background-color: #ADD8E6">
</font></td>
<td><font face="Times New Roman, Times, serif"><strong>Date Contact Again</strong></font></td>
<td><font face="Times New Roman, Times, serif">
<?php DateSelector("datecontactagain_",""); ?>
</font></td>
</tr>
<tr>
<td><font face="Times New Roman, Times, serif"><strong>Address(2) </strong></font></td>
<td><font face="Times New Roman, Times, serif">
<input name="address2" type="text" size="20"style="color: #000000;
background-color: #ADD8E6">
</font></td>
<td><font face="Times New Roman, Times, serif"><strong>OID</strong></font></td>
<td><font face="Times New Roman, Times, serif">
<input name="org_id" type="text"style="color: #000000;
background-color: #ADD8E6" size="5">
</font></td>
</tr>
<tr>
<td><font face="Times New Roman, Times, serif"><strong>City</strong></font></td>
<td><font face="Times New Roman, Times, serif">
<input name="city" type="text" size="20"style="color: #000000;
background-color: #ADD8E6">
</font></td>
<td><font face="Times New Roman, Times, serif"> </font></td>
<td> </td>
</tr>
<tr>
<td height="43"><font face="Times New Roman, Times, serif"><strong>Post
Code</strong></font></td>
<td><font face="Times New Roman, Times, serif">
<input name="postcode" type="text" size="7"style="color: #000000;
background-color: #ADD8E6">
</font></td>
<td><font face="Times New Roman, Times, serif"> </font></td>
<td> </td>
</tr>
</table>
<input type="submit" name="submit" value = "Enter Information">
</form>
<p>
And once I click submit the data entered in the above form is passed onto my insert script which inserts the data.
Code: Select all
<?php
/*Connecting, selecting database*/
$link = mysql_connect("xxx", "xxxxx", "xxxxx")
or die("Could not connect : " . mysql_error());
mysql_select_db("contact_management_system",$link) or die("Could not select database");
$var1 = $_POST["dateoflastcontact_Year"];
$var2 = $_POST["dateoflastcontact_Day"];
$var3 = $_POST["dateoflastcontact_Month]";
$dateoflastcontact = $var1."-".$var3."-".$var2;
$sql = "INSERT INTO people (person_id, salutation, firstname, surname, organisation, role, address1, address2, city, postcode, telephone, mobile, fax, dateoflastcontact, datecontactagain, notes, email, org_id )
VALUES ('$person_id','$salutation','$firstname','$surname', '$organisation', '$role', '$address1', '$address2', '$city', '$postcode', '$telephone', '$mobile', '$fax', '$dateoflastcontact', '$datecontactagain', '$notes', '$email','$org_id')";
$result = mysql_query($ sql, $link) or die ( mysql_error($link));;
header ("location: http://www.soi.city.ac.uk/organisation/ ... eople.html");
?>
this had been working perfectly well before and I could always go back to my previous file as I have a copy of it to get it working again.
Its just I want this dateselector function to insert dates correctly. this is where Im having problems, can anyone take a look please especially Pimpatastic as he was initially giving me advice.