Php update is not working

  1. <?php
  2. session_start();

  3. if (isset($_SESSION[“userid”])) userid = _SESSION[“userid”];

  4. 
    
  5. else $userid = “”;

  6. 
    
  7. if (isset($_SESSION[“username”])) username = _SESSION[“username”];

  8. 
    
  9. else $username = “”;

  10. 
    
  11. if (isset($_SESSION[“userpass”])) userpass = _SESSION[“userpass”];

  12. 
    
  13. else $userpass = “”;

  14. 
    
  15. title_name = _POST[“title_name”];

  16. 
    
  17. genre = _POST[“genre”];

  18. 
    
  19. introduction = _POST[“introduction”];

  20. 
    
  21. $regist_day = date(“Y-m-d (H:i)”);

  22. 
    
  23. $upload_dir = ‘./img/’;

  24. 
    
  25. if ($upfile_name && !$upfile_error)

  26. 
    
  27. {

  28. 
    
  29. $file = explode(".", $upfile_name);
    
  30. 
    
  31. $file_name = $file[0];
    
  32. 
    
  33. $file_ext  = $file[1];
    
  34. 
    
  35. $new_file_name = date("Y_m_d_H_i_s");
    
  36. 
    
  37. $new_file_name = $upfile_name.$new_file_name;
    
  38. 
    
  39. $copied_file_name = $new_file_name.".".$file_ext;
    
  40. 
    
  41. $uploaded_file = $upload_dir.$copied_file_name;
    
  42. 
    
  43. if( $upfile_size  > 20000000 ) { 
    
  44. 
    
  45. 		echo("
    
  46. 
    
  47. 		<script>
    
  48. 
    
  49. 		alert('(20MB) FAIL ');
    
  50. 
    
  51. 		history.go(-1)
    
  52. 
    
  53. 		</script>
    
  54. 
    
  55. 		");
    
  56. 
    
  57. 		exit;
    
  58. 
    
  59. }
    
  60. 
    
  61. if (!move_uploaded_file($upfile_tmp_name, $uploaded_file) )
    
  62. 
    
  63. {
    
  64. 
    
  65. 		echo("
    
  66. 
    
  67.    		<script>
    
  68. 
    
  69.    		alert('FAIL.');
    
  70. 
    
  71.    		history.go(-1)
    
  72. 
    
  73.    		</script>
    
  74. 
    
  75.    	");
    
  76. 
    
  77.    	exit;
    
  78. 
    
  79. }

  80. 
    
  81. }

  82. 
    
  83. $con = mysqli_connect(“localhost”, “user1”, “12345”, “testdb”);

  84. 
    
  85. mysqli_set_charset($con, ‘utf8’);

  86. 
    
  87. $sql = “update uploadnovel set title_name=’$title_name’, genre=’$genre’ , upfile_name=’$upfile_name’, upfile_type=’$upfile_type’, file_copied=’$file_copied’, introduction=’$introduction’, where id=’$id’ AND title_name=’$title_name’”;

  88. 
    
  89. mysqli_query($con, $sql);

  90. 
    
  91. mysqli_close($con);

  92. 
    
  93. ?>

  94. I’m so sorry, but I’ve been coding for a few days.i’m beginner. I’ve had a really difficult task.I don’t know how to declare variables.I really don’t know why update doesn’t work. I’m really tired.