// Written by Brad Simonin.
// This PHP page reads in information from an HTML Form and then
// loads the data into an Access 2000 database using the PHP ODBC functions.
$IPAddress = $REMOTE_ADDR;
$TheRequest = $REQUEST_METHOD;
?>
Brad Simonin's PHP GuestBook Processor
$IPAddress = trim($IPAddress);
if (empty($IPAddress))
$IPAddress = "null";
else
$IPAddress = "'" . $IPAddress . "'";
$Name = $strName;
$Name = trim($Name);
$DisplayName = $Name;
if (empty($Name))
$Name = "null";
else
{
$Name = str_replace("'","`",$Name);
$Name = str_replace(","," ",$Name);
$Name = str_replace("."," ",$Name);
$Name = strtoupper($Name);
$Name = "'" . $Name . "'";
}
$State = $strState;
$State = trim($State);
if (empty($State))
$State = "null";
else
{
$State = str_replace("'","`",$State);
$State = str_replace(","," ",$State);
$State = str_replace("."," ",$State);
$State = strtoupper($State);
$State = "'" . $State . "'";
}
$Occupation = $strCompanyOccupation;
$Occupation = trim($Occupation);
if (empty($Occupation))
$Occupation = "null";
else
{
$Occupation = str_replace("'","`",$Occupation);
$Occupation = str_replace(","," ",$Occupation);
$Occupation = str_replace("."," ",$Occupation);
$Occupation = strtoupper($Occupation);
$Occupation = "'" . $Occupation . "'";
}
$City = $strCity;
$City = trim($City);
if (empty($City))
$City = "null";
else
{
$City = str_replace("'","`",$City);
$City = str_replace(","," ",$City);
$City = str_replace("."," ",$City);
$City = strtoupper($City);
$City = "'" . $City . "'";
}
$Email = $strEmail;
$Email = trim($Email);
if (empty($Email))
$Email = "null";
else
{
$Email = str_replace("'","`",$Email);
$Email = "'" . $Email . "'";
}
$WebPage = $strWebSite;
$WebPage = trim($WebPage);
if (empty($WebPage))
$WebPage = "null";
else
{
$WebPage = str_replace("'","`",$WebPage);
$ChkWebPage = strpos($WebPage,"http://",0);
if (gettype($ChkWebPage) != "integer")
{
$WebPage = "http://" . $WebPage;
}
$WebPage = "'" . $WebPage . "'";
}
$Comments = $strComment;
$Comments = trim($Comments);
if (empty($Comments))
$Comments = "null";
else
{
$Comments = str_replace("'","`",$Comments);
$Comments = "'" . $Comments . "'";
}
$SqlString = "INSERT INTO Brads_GuestBook " .
"(Name, Company_Occupation, City, State, E_Mail, Web_Page, " .
"Comments, Users_IP_Address, Time_Stamp, Type) " .
"VALUES ($Name, $Occupation, " .
"$City, $State, $Email, $WebPage, $Comments, " .
"$IPAddress, Now(), 'PHP')";
$db_connect = odbc_connect("Brad2000","","");
$execute_SqlString = odbc_exec($db_connect,$SqlString);
odbc_close($db_connect);
?>
Thank You echo $DisplayName ?> for signing my Guest Book.
Or to view the source code of this PHP Page click on the
following hyperlink: ProcessGuestBookForm.php3