PHP   15

updatephp.txt

Guest on 14th September 2021 08:58:13 PM

  1. <?php
  2. if (!(session_is_registered("id")))
  3. $url= "Location:index.php";
  4. header($url);
  5. }
  6.  
  7. $dbservertype='mysql';
  8. $servername='localhost';
  9. // username and password to log onto db server
  10. $dbusername='root';
  11. $dbpassword='';
  12. // name of database
  13. $dbname='data2';
  14. ////////////////////////////////////////
  15. ////// DONOT EDIT BELOW  /////////
  16. ///////////////////////////////////////
  17. connecttodb($servername,$dbname,$dbusername,$dbpassword);
  18. function connecttodb($servername,$dbname,$dbuser,$dbpassword)
  19. {
  20. global $link;
  21. $link=mysql_connect ("$servername","$dbuser","$dbpassword");
  22. if(!$link){die("Could not connect to MySQL");}
  23. mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
  24. }
  25. //////////////////////////////
  26.  
  27.        $userid = $_GET['id'];
  28.  
  29.                 $result = mysql_query("SELECT * FROM plus_signup WHERE userid = '$userid'");
  30.  
  31.            while($row = mysql_fetch_array($result))
  32.            {
  33.            $userid=$_POST['userid'];
  34.            $password=$_POST['password'];
  35.            $password2=$_POST['password2'];
  36.            $agree=$_POST['agree'];
  37.            $todo=$_POST['todo'];
  38.            $email=$_POST['email'];
  39.            $name=$_POST['name'];
  40.            $sex=$_POST['sex'];
  41.            $cpp=$_POST['cpp'];
  42.                  }
  43.                 ?>
  44.  
  45. <?php
  46.  
  47. //The files have a link on a page for downloading
  48. //and filenames are also put in the progress bar so
  49. //the file can be viewed in the browser (ie. PDF files)
  50. //so replace a few characters.  Since the file links are
  51. //loaded onto another page via php and filenames
  52. //are displayed, I wanted to use this method instead
  53. //of url_encode() [just looks funny when displayed]
  54.  
  55. $SafeFile = $HTTP_POST_FILES['ufile']['name'];
  56. $SafeFile = str_replace("#", "No.", $SafeFile);
  57. $SafeFile = str_replace("$", "Dollar", $SafeFile);
  58. $SafeFile = str_replace("%", "Percent", $SafeFile);
  59. $SafeFile = str_replace("^", "", $SafeFile);
  60. $SafeFile = str_replace("&", "and", $SafeFile);
  61. $SafeFile = str_replace("*", "", $SafeFile);
  62. $SafeFile = str_replace("?", "", $SafeFile);
  63.  
  64. $uploaddir = "uploads/";
  65. $path = $uploaddir.$SafeFile;
  66.  
  67. if($ufile != none){ //AS LONG AS A FILE WAS SELECTED...
  68.  
  69.     if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)){ //IF IT HAS BEEN COPIED...
  70.  
  71.         //GET FILE NAME
  72.         $theFileName = $HTTP_POST_FILES['ufile']['name'];
  73.  
  74.         //GET FILE SIZE
  75.         $theFileSize = $HTTP_POST_FILES['ufile']['size'];
  76.  
  77.         if ($theFileSize>999999){ //IF GREATER THAN 999KB, DISPLAY AS MB
  78.             $theDiv = $theFileSize / 1000000;
  79.             $theFileSize = round($theDiv, 1)." MB"; //round($WhatToRound, $DecimalPlaces)
  80.         } else { //OTHERWISE DISPLAY AS KB
  81.             $theDiv = $theFileSize / 1000;
  82.             $theFileSize = round($theDiv, 1)." KB"; //round($WhatToRound, $DecimalPlaces)
  83.         }
  84.  
  85. echo <<<UPLS
  86. <table cellpadding="5" width="300">
  87. <tr>
  88.     <td align="Center" colspan="2"><font color="#009900"><b>Upload Successful</b></font></td>
  89. </tr>
  90. <tr>
  91.     <td align="right"><b>File Name: </b></td>
  92.     <td align="left">$theFileName</td>
  93. </tr>
  94. <tr>
  95.     <td align="right"><b>File Size: </b></td>
  96.     <td align="left">$theFileSize</td>
  97. </tr>
  98. <tr>
  99.     <td align="right"><b>Status </b></td>
  100.     <td align="left">Complete</td>
  101. </tr>
  102. </table>
  103. <form action="update.php" method="post">
  104. <input type="file"  name="ufile" />
  105. <input type="submit" value="Confirm" />
  106. </form>
  107.  
  108.  
  109.  
  110. </td></tr></table>
  111.  
  112. UPLS;
  113.  
  114.     } else {
  115.  
  116. //PRINT AN ERROR IF THE FILE COULD NOT BE COPIED
  117. echo <<<UPLF
  118. <table cellpadding="5" width="80%">
  119. <tr>
  120. <td align="Center" colspan="2"><font color=\"#C80000\"><b>File could not be uploaded</b></font></td>
  121. </tr>
  122.  
  123. </table>
  124.  
  125. UPLF;
  126.     }
  127. }
  128.  
  129. ?>

Raw Paste


Login or Register to edit or fork this paste. It's free.