Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. <?php
  2.  
  3. function setting_email_smtp() {
  4. $host = $_POST["host"];
  5. $port = $_POST["port"];
  6. $username = $_POST["username"];
  7. $password = $_POST["password"];
  8. $send_from = $_POST["send_from"];
  9. $notice = $_POST["notice"];
  10. //insert
  11. if (isset($_POST['insert'])) {
  12. global $wpdb;
  13. $table_name = $wpdb->prefix . "dathangnhanh_email";
  14.  
  15. $wpdb->insert(
  16. $table_name, //table
  17. array('host' => $host, 'port' => $port, 'username' => $username,
  18. 'password' => $password, 'send_from' => $send_from, 'notice' => $notice), //data
  19. array('%s', '%s') //data format
  20. );
  21. }
  22. else {// value to update selecting
  23. $donhang = $wpdb->get_results($wpdb->prepare("SELECT host,port,username,password,send_from,notice from $table_name where id=%s", $id));
  24. foreach ($donhang as $s) {
  25. $host = $s->host;
  26. $port = $s->port;
  27. $username = $s->username;
  28. $password = $s->password;
  29. $send_from = $s->send_from;
  30. $notice = $s->notice;
  31. }
  32. }
  33. ?>
  34. <div>
  35. <h2>Setup Email</h2>
  36.  
  37. <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
  38. <table>
  39. <tr>
  40. <th>SMTP Host</th>
  41. <td><input type="text" name="host" value="<?php echo $host; ?>" placeholder="smtp.gmail.com" /></td>
  42. </tr>
  43. <tr>
  44. <th>SMTP Port</th>
  45. <td><input type="text" name="port" value="<?php echo $port; ?>" placeholder="465" /></td>
  46. </tr>
  47. <tr>
  48. <th>SMTP User</th>
  49. <td><input type="text" name="username" value="<?php echo $username; ?>" placeholder="email@gmail.com" /></td>
  50. </tr>
  51. <tr>
  52. <th>SMTP Password</th>
  53. <td><input type="password" name="password" value="<?php echo $password; ?>" placeholder="Your password" /></td>
  54. </tr>
  55. <tr>
  56. <th>SMTP Send From</th>
  57. <td><input type="text" name="send_from" value="<?php echo $send_from; ?>" placeholder="admin@gmail.com" /></td>
  58. </tr>
  59. <tr>
  60. <th>Notice Email</th>
  61. <td><input type="text" name="notice" value="<?php echo $notice; ?>" placeholder="youremail@gmail.com" /></td>
  62. </tr>
  63. </table>
  64. <input type='submit' name="insert" value='Save' class='button'>
  65. </form>
  66. </div>
  67. <?php
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement