Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. <?php
  2. include('index.php');
  3. include('db.php');
  4. ini_set('auto_detect_line_endings',TRUE);
  5. /*
  6. if($_GET['reset'] == 1)
  7. mysqli_query($sql,'TRUNCATE expressinput') or die(mysqli_error($sql));
  8. if($_GET['reset'] == 2)
  9. mysqli_query($sql,'TRUNCATE expresskeywords') or die(mysqli_error($sql));
  10. */
  11. echo "<br>";
  12. if ($_POST['companies'] && is_numeric($_POST['searchid'])) {
  13. $mydata = explode("\n",$_POST['companies']);
  14. $searchid = mysqli_real_escape_string($sql,$_POST['searchid']);
  15.  
  16. if( $stmt = mysqli_prepare($sql,"SELECT id FROM schedule WHERE id=?")) {
  17. mysqli_stmt_bind_param($stmt,"i",$searchid);
  18. mysqli_stmt_execute($stmt);
  19. mysqli_stmt_store_result($stmt);
  20. if(mysqli_stmt_num_rows($stmt) == 0)
  21. { echo "No such searchid: $searchid<br>";exit; }
  22. } else { echo "Mysql error\n"; exit; }
  23. mysqli_stmt_close($stmt);
  24. foreach($mydata as $piece)
  25. {
  26. $piece = str_replace("\r","",trim(mysqli_real_escape_string($sql,$piece)));
  27. if (strlen($piece) > 3)
  28. {
  29. if( $stmt = mysqli_prepare($sql,'SELECT id FROM input WHERE searchid =? AND company=?'))
  30. {
  31. mysqli_stmt_bind_param($stmt,"is",$searchid,$piece);
  32. mysqli_stmt_execute($stmt);
  33. mysqli_stmt_store_result($stmt);
  34. if(mysqli_stmt_num_rows($stmt) == 0)
  35. if( $stmt = mysqli_prepare($sql,'INSERT INTO input (searchid,company,status) VALUES (?,?,"active")'))
  36. {
  37. mysqli_stmt_bind_param($stmt,"is",$searchid,$piece);
  38. mysqli_stmt_execute($stmt);
  39. printf("%d Row inserted with '$piece'<br>", mysqli_stmt_affected_rows($stmt));
  40. mysqli_stmt_close($stmt);
  41. } else { echo "Mysql error\n"; exit; }
  42. } else { echo "Mysql error\n"; exit; }
  43. }
  44. }
  45. echo "<br><br><b>COMPANIES SUCCESSFULLY INSERTED FOR SEARCHID $searchid</b><br>";
  46. }
  47.  
  48.  
  49. ?>
  50.  
  51. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  52. <html xmlns="http://www.w3.org/1999/xhtml">
  53. <head>
  54. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  55. <title>Scheduled Tasks - Companies Importer</title>
  56. </head>
  57.  
  58. <body>
  59. <p><b>Data will be added to the input table for the given searchid (Scheduled Task ID).</b></p>
  60.  
  61. <form action="" method="post" name="form1" id="form1">
  62. Input companies one per line below for searchid : <select name="searchid"><?php
  63. $searchids = mysqli_query($sql,'SELECT id FROM schedule') or die(mysqli_error($sql));
  64. while($rowu = mysqli_fetch_array($searchids))
  65. echo '<option value="'. $rowu[0] .'">'. $rowu[0] .'</option>';
  66.  
  67. ?></select><br />
  68. <textarea rows="30" cols="50" name="companies"></textarea>
  69. <input type="submit" name="Submit" value="Submit" />
  70. </form>
  71.  
  72. </body>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement