Jump to content

Pls I Want Urgent Help.pls Somebody Help Me Run This Project.


grush1234
 Share

Recommended Posts

My Project Name is User Adaptive Interface like as google user adaptive interfaceUser Adaptive Interface .txt.I used PHP language for this project.I already complete my source code.I used Mysql as database.So pls help me to correct this code and run this software. Following are my Source codes.Source code separated by file name such as index.php, search page.php etc.It's my academic project and I don't know much in PHP.That's why i want help from PHP intelligent developers.So plssss Help Me.following are my source code.

[php}
1)Index.php<!--include procedure file which also makes available the db include file--> <?php include'func.inc.php';if(loggedin()){header("Location:index.php");exit();} $con = mysql_connect("localhost","admin",""); if (!$con)   {   die('Could not connect: ' . mysql_error());   }   else   echo "DB connected"; ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Search</title></head> <body><img src="nactemlogo.gif" alt="NacTemLogo" align="left"/><img src="metlogo.jpg"   alt="MetLogo"   height="100" width="150"  align="right"/><p><br><h1 align="center"> User Adaptive Search </h1><br/> <form action="" method="post"> </form>  </p><strong>Please Enter Your memorable word and place Name To Associate With Machine Independent Profile<table width="100%"><tr><td><input type="text" name="mword" ><input type="text" name="mplace"><input type="submit" name="rememberme" value="Remember me"></td></strong></tr></table></form>  </body> </html> 2)Searchpage.php<!--include procedure file which also makes available the db include file--> <?php include'func.inc.php';if(loggedin()){header("Location:index.php");exit();}?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   "http://www.w3.org/TR/html4/loose.dtd">   <!Below Code Create For User Able To Search Keywords And Also Be Able To View Their Status i.e.Novice Or Pro><html> <head>  <title>Search</title></head> <body><img src="nactemlogo.gif" alt="NacTemLogo" align="left"/><img src="metlogo.jpg"   alt="MetLogo"   height="100" width="150" align="right"/><p><br><h1 align="center"> User Adaptive Search </h1><br/> <form action="index.php" method="POST"></p><table width="50%"><tr><td><input type="text" name="keywords"><input type="submit"  value="Search"></td></tr></table></form><?php//$_POST as form is submitted using POST dataif(isset($_POST['keywords'])){//create variable for handle the 's' in the results(s)$s_handler="";/*variable keywords is equal to what user types into the text box to eliminateany spaces entered by the user  trim function used for this purposewhere as htmlentities used for takes any html and store into its simplest form andmysql_real_escape_string is used to escape any data that could be potentially used for sql injections */ $keywords=mysql_real_escape_string (htmlentities(trim($_POST['keywords']))); //array used for store list of errors .$errors=array();//Check if any keyword enteredif(empty ($keywords)){     $errors[]='Please Enter Keyword to Search';     // using string length function check if keywords lenght is less than 2     }     else     if(strlen($keywords)<2)     {      $errors[]='your keyword must be atleast 2 charcters long';      }      // keyword_results() procedure checks if there are any results to display      else      if(keyword_results($keywords)==false)      {      $errors[]='your search for <strong>'.$keywords.'</strong> has not returned any results';      }      if(empty($errors))      {      $stackcheck=$_COOKIE["status"];      $prostat=substr($stackcheck,0,3);      $novstat=substr($stackcheck,0,6);       //if(cookies/session set to novice then      //function to search for the keywords      if($novstat=="novice")      {          $results=keyword_results_novice($keywords);          $results_num=count($results);          $s_handler=($results_num !=1)? 's':"";          echo '<p>Your Search for <storng>'.$keywords.'</strong> Has Returned<strong>          ',$results_num,'</strong> result',          $s_handler,'</p>';          // foreach function iterate over arrays.In each iteration,the value of the current element is assigned to $result          foreach($results as $result)          {            echo'<p><storng>'.$result['title'].'</strong><br>','<a href=display.php?id_pass='.$result['id'].' target=_blank>            <font color=green><storng>Basic Information:</strong>'.$result['basics'].'</a></font><br>','<a href=dispaly.php?id_pass='.$result['id'].'            target=_blank>'.$result['description'].'</a><br>','<b><font size=2> This Areticle Was Posted On'.$result['date_posted'].'and has a rating of';            printf("%0.2f",$result['rating']).'</b></font></p>';            }            }            //if cookies set to pro then            else            if($prostat=="pro")            {            //function to search the keywords            $results=keyword_results_pro($keywords);            $results_num=count($results);            $s_handler=($results_num!=1)?:"";            echo'<p>Your Search For <strong>'.$keywords.'</strong> Has Returned<strong>          ',$results_num,'</strong> result',          $s_handler,'</p>';          foreach($results as $result)          {            echo'<p><storng>'.$result['title'].'</strong><br>','<a href=display.php?id_pass='.$result['id'].' +btarget=_blank>            <font color=green><storng>Basic Information:</strong></font><font color=black>'.$result['basics'].'</a><br>','            <a href=dispaly.php?id_pass='.$result['id'].'+a target=_blank></font><font color=blue><storng>Advanced Information:</storng>            </font><font color=black> '.$result['description'].'</a><br>','<b></font>s<font size=2> This Areticle Was Posted On'.$result['date_posted'].'            and has a rating of</font>';            printf("%0.2f",$result['rating']).'</b></font></p>';            }            }            foreach($errors as $error)            {              echo $error,'</br>';              }          }             }             ?> </body> </html> 3)Display.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title></title></head> <body> <?phpinclude'db.inc.php';include'func.inc.php'; //process users request to change the rating submissionif(isset($_POST['submit'])){//get the id and rating selected in the form below$id_post=$_POST['id'];$rating_post=$_POST['rating'];//creating get query variable in order to select required table row$get=mysql_query("SELECT * FROM help_articles WHERE id=$id_post");//while previous $get retrieves values from table and storing it into $get$get=mysql_fetch_assoc($get);//retrieving previous rating related to this article$get=$get['rating'];//getting row count to cater for no. of ratingsif($get==0){$newrating=$get+$rating_post;}//new rating will be equal to old rating plus the new ratingelse{$newrating=($get+$rating_post)/2;} //creating a query to update rating in the database$update=mysql_query("UPDATE help_articles SET rating='$newrating' WHERE id=$id_post");  header('Location:close.php');}else{$id_full=$_GET['id_pass'];//substr function to identify the article id$id=substr($id_full,0,1);//seperating the appended(a/b)info to change status for the user$statusinfo=substr($id_full,-1); /*to tset program functionalityecho $statusinfo;*/ if($statusinfo=="b"){$cstatus="";//run a function to change user status i.e cookies/session$cstatus =$_COOKIE["status"];//echo $cstatus .'this is cookie status';$tstatus ="+b";$nstatus =$cstatus."".$tstatus;//echo $nstatus;//reset cookie if set//if(cookie_check());//{//setcookie("status","",timt()-99999999);reset_cookie($nstatus); //} /*if(cookie_check()==FALSE);{reset_cookie($nstatus);}*/ //else if reset session if set if($statusinfo=="a"){$cstatus="";//run a function to change user status i.e cookies/session$cstatus =$_COOKIE["status"];//echo $cstatus .'this is cookie status';$tstatus ="+a";$nstatus =$cstatus."".$tstatus;//echo $nstatus;//reset cookie if set//if(cookie_check());//{//setcookie("status","",timt()-99999999);reset_cookie($nstatus);} //displaying the results based on the resulted clicked by the user $query =$display="";$display=display_results($id); foreach($display as $display){  echo'<p><strong>'.$display['display_title'].'</p>','Basic Information :</strong><br>'.$display['display_basics'].  '<p><strong>',' Advance Information: Steps To Be Followed</strong><br>'nl2br($display['display_description']).  '<p><b><font size=2> This Article Was Posted On '.$display['display_date_posted'].'and has a rating of ';  printf("%0.2f",$display['display_rating']).'</b></font></p>';  }}?><form action ="display.php" method ="POST"><strong>Choose rating:</strong><br/><select name="rating"><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option></select> <input type="hidden" name="id" value="<?php echo $id;?>"><p/><input type ="submit" name="submit" value="rate this!"><!Close the Window without leaving feedback!><?phpclose_window();?></form> </body> </html>  4)Functions.php <?php  //Include database file used for connect to database include 'db.inc.php'; session_start(); //create a function to display results for novice user  function keyword_results_novice($keywords) {     //creating three variables     $returned_results=array();      //construct for where part of the mysql query     $where="";     /* spilitting keywords that were entered into the text box     using preg_spilt to cater for blank spaces*/     $keywords=preg_split('/[\s]+/',$keywords);     //returning of how many elements of array constitue keyword entered by user     $total_keywords=count($keywords);     //constructing where clause mysql search query     //getting the key of matched keywords from the database     foreach($keywords as $key=>$keyword)     {     //. used for append onto     $where.="'keywords' LIKE '%$keyword%'";     if ($key!=($total_keywords-1))     {       $where.="OR";       }     }        //query for get information from database and used order by clauseon id to sort result in ascending order.       $results="SELECT'id','rating','title','basics',LEFT('description',80) as 'description','date_posted'       FROM 'help_articles' WHERE $where ORDER BY 'id' ASC";       /*  here used ternary operator (? that can replace a single if/else clause.       This operator takes three expressions. If the first one is true the second expression is evaluated and returned,       and if itís false the third one is.  */        $results_num=($results=mysql_query($results))? mysql_num_rows($results): 0;       //here used the comparison operators compare two values and return either true or false.       if($results_num=== 0)       {        return false;       }       else       {          while($results_row = mysql_fetch_assoc($results))       {          $returned_results[]=array(          'id'=>$results_row['id'],          'rating'=>$results_row['rating'],          'title'=>$results_row['title'],          'basics'=>$results_row['basics'],          'description'=>$results_row['description'],          'date_posted'=>$results_row['date_posted']          );        }          return $returned_results;          }       }        //create a function to display results for pro user      function keyword_results_pro($keywords) {     //creating three variables     $returned_results=array();      //construct for where part of the mysql query     $where="";     /* spilitting keywords that were entered into the text box     using preg_spilt to cater for blank spaces*/     $keywords=preg_split('/[\s]+/',$keywords);     //returning of how many elements of array constitue keyword entered by user     $total_keywords=count($keywords);     //constructing where clause mysql search query     //getting the key of matched keywords from the database     foreach($keywords as $key=>$keyword)     {     //. used for append onto     $where.="'keywords' LIKE '%$keyword%'";     if ($key!=($total_keywords-1))     {       $where.="OR";       }       }        //query for get information from database and used order by clause on rating to sort result in descending order.       $results="SELECT'id','rating','title','basics',LEFT('description',80) as 'description','date_posted'       FROM 'help_articles' WHERE $where ORDER BY 'rating' DESC";       /*  here used ternary operator (? that can replace a single if/else clause.       This operator takes three expressions. If the first one is true the second expression is evaluated and returned,       and if itís false the third one is.  */        $results_num=($results=mysql_query($results))? mysql_num_rows($results): 0;       //here used the comparison operators compare two values and return either true or false.       if($results_num=== 0)       {        return false;       }       else       {          while($results_row = mysql_fetch_assoc($results))       {          $returned_results[]=array(          'id'=>$results_row['id'],          'rating'=>$results_row['rating'],          'title'=>$results_row['title'],          'basics'=>$results_row['basics'],          'description'=>$results_row['description'],          'date_posted'=>$results_row['date_posted']          );          }          return $returned_results;          }       } //create a function to take in one parameter sent by index.php function keyword_results($keywords){// creating three variables$returned_results=array();//construct for where part of the mysql query$where="";/*spilting keywords that were entered into the text boxusing preg_spilt to cater for blank spaces*/ $keywords=preg_split('/[\s]+/',$keywords);//returning of how many elements of array constitue keywords entered by user$total_keywords=count($keywords);//constructing where clause for mysql search query//getting the key of matched keywords from the databaseforeach($keywords as $key =>$keyword){//.means append onto.. $where.="'keywords' LIKE '%$keyword%'";if($key!=($total_keywords-1)){}}$results="SELECT'id','rating','title','basics',LEFT('description',80) as 'description','date_posted' FROM 'help_articles'WHERE $where ORDER BY 'id'ASC";$results_num=($results=mysql_query($results))? mysql_num_rows($results):0;if($results_num===0){return false;}else{ while($results_row=mysql_fectch_assoc($results)) { $returned_results[]=array(                           'id'=>$results_row['id'],                           'rating'=>$results_row['rating'],                           'title'=>$results_row['title'],                           'basics'=>$results_row['basics'],                           'description'=>$results_row['description'],                           'date_posted'=>$results_row['date_posted']                           );}return $returned_results;}} //create a function to display the clicked result setfunction display_results($id_display){//comments$display_record=array();$record=mysql_query("SELECT 'id','rating','title','basics','description','date_posted' FROM'help_articles' WHERE 'id'='id_display'"); while($results_row=mysql_fectch_assoc($results)) { $display_record[]=array(                           'id'=>$results_row['id'],                           'rating'=>$results_row['rating'],                           'title'=>$results_row['title'],                           'basics'=>$results_row['basics'],                           'description'=>$results_row['description'],                           'date_posted'=>$results_row['date_posted']                           ); return $display_record;}}//function to close window -that can be called from various pagesfunction close_window(){echo"<input type='submit' name='close' value='Close this window!' onclick='self.close()'>";} //function to search for existing m_word into the databasefunction mword_exist($mword){ $query=mysql_query("SELECT COUNT(1) FROM 'users' WHERE 'm_word'='{$mword}'"); return(mysql_result($query,0)=='0') ? false:true; }  //function to add m_word to the database function add_det($mword,$mplace,$status) { $ad= mysql_query ("INSERT into 'users'('m_word','m_place','status') VALUES ('$mword','$mplace','$status')"); } // function to update the status in the database function up_det($mword,$mplace,$status) { $up=mysql_query("UPDATE 'users' SET 'status'='$status' WHERE 'm_word'='{$mword}' AND 'm_place'='{$mplace}'"); }  // session set function function session_check() { if(isset($_SESSION['status'])) { $sessionset=TRUE; return $sessionset } }  //cookie check function function cookie_check() { if(isset($_COOKIE['status'])) { $cookieset=TRUE; return $cookieset; }}  // cookie reset function function reset_cookie($nstatus) { $nustatus=""; $nustatus=substr($nstatus,-8); $cstatus=$_COOKIE["status"]; $cmword=$_COOKIE["mword"]; $cmplace=$_COOKIE["mplace"];  if($nstatus=="+b+b+b+b") {  $nstatus="novice";  $cstaus=$nstatus;  up_det($cmword,$cmplace,$cstatus); } else if($nstatus=="+a+a+a+a") {  $nstatus="pro";  $cstaus=$nstatus;  up_det($cmword,$cmplace,$cstatus); } ?>[/PHP]

Link to comment
Share on other sites

where have you been stucked? what problems are you facing?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...