Process Form function():
This is the core part of the upload program. After finishing filtering, removing common words and duplicate words,
this function is called. First this function inserts the title and abstract in the content table. The newly generated
content id stored in
this function is called. First this function inserts the title and abstract in the content table. The newly generated
content id stored in
$contentId
. Then it updates keyword and link table.
For every word in the
inserts the key id, content id in to link table. Conversely, if the word is not found, it inserts the new word in keyword
table, the generated new key id is stored in
key id content id in link table.
$wordMap
array, if the word is already exists in keyword table, itinserts the key id, content id in to link table. Conversely, if the word is not found, it inserts the new word in keyword
table, the generated new key id is stored in
$keyId
. Then it updates link table by insertingkey id content id in link table.
<?php
function ProcessForm($title ,$body){
global
$allWords;
$tempWordList = ExtractWords( $body );
$wordList = FilterCommonAndDuplicateWords($tempWordList);
// insert into content
mysql_query( sprintf( "INSERT INTO content (title, abstract) VALUES ('%s', '%s')",
mysql_escape_string($title), mysql_escape_string($body) ) );
//store the newly generated content id in $contentId
$contentId = mysql_insert_id();
// insert all the new words and links
while(list($word,$val)=each($wordList)) {
$keyId = "";
if ( !$allWords[$word] ) {
mysql_query( sprintf( "INSERT INTO keytable ( keyword ) VALUES ( '%s' )",
mysql_escape_string($word) ) );
$keyId = mysql_insert_id();
$allWords[$word] = $keyId;
}
else {
$keyId = $allWords[$word];
}
// insert the link
mysql_query( sprintf( "INSERT INTO link (keyid, contid) VALUES ( %d, %d )", $keyId, $contentId ) );
}
//End of Processing Form.
}
?>