Advertisement
Guest User

Untitled

a guest
Aug 10th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. <?php
  2.  
  3. if(!count($_POST)){
  4. die();
  5. }
  6. if(isset($_POST['subject'])){
  7. $subject = $_POST['subject'];
  8. } else {
  9. $subject = 'Subscription Request';
  10. }
  11. mail('email@gmail.com,email@email.com',$subject,print_r($_POST,true));
  12.  
  13.  
  14. $servername = "localhost";
  15. $username = "inthemoodus1";
  16. $password = "fQtl+QOZ5kIC";
  17. $dbname = "email";
  18.  
  19. //try {
  20. //Creating connection for mysql
  21. $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  22. // set the PDO error mode to exception
  23. //$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  24. //echo "Connected successfully";
  25.  
  26. // $sql = "INSERT INTO emails (emailaddress)
  27. // VALUES ('".$_POST['email']."')";
  28. // if ($conn->query($sql)) {
  29. // //echo '<p style="color:green">successfully added ' . $email . ' to our database <p/>';
  30. // }
  31. // else{
  32. // //echo '<p style="color:red;font-weight:bold;">unable to add ' . $email . ' to our database <p/>';
  33. // }
  34.  
  35. $sql = "SELECT id FROM emails
  36. WHERE emailaddress = ('".$_POST['email']."')";
  37. if ($result = $conn->query($sql)) {
  38. //echo '<p style="color:green">successfully added ' . $email . ' to our database <p/>';
  39. $id = current($result)['id'];
  40. }
  41. else{
  42. //echo '<p style="color:red;font-weight:bold;">unable to add ' . $email . ' to our database <p/>';
  43. }
  44.  
  45. $sql = "UPDATE emails
  46. SET first_name = ('".$_POST['firstname']."'),
  47. last_name = ('".$_POST['lastname']."'),
  48. first_name2 = ('".$_POST['firstname2']."'),
  49. last_name2 = ('".$_POST['lastname2']."'),
  50. email = ('".$_POST['email']."'),
  51. device = ('".$_POST['radio1']."'),
  52. device2 = ('".$_POST['radio2']."')
  53.  
  54. WHERE id = $id";
  55.  
  56. if ($conn->query($sql)) {
  57.  
  58. //echo '<p style="color:green">successfully added ' . $email . ' to our database <p/>';
  59. }
  60. else{
  61. //echo '<p style="color:red;font-weight:bold;">unable to add ' . $email . ' to our database <p/>';
  62. }
  63.  
  64. $sql = "INSERT INTO emails (emailaddress, first_name, last_name, device)
  65. VALUES (
  66. '".$_POST['partner_email']."',
  67. '".$_POST['partner_firstN']."',
  68. '".$_POST['partner_lastN']."',
  69. '".$_POST['radio2']."'
  70. )";
  71. if ($conn->query($sql)) {
  72. //echo '<p style="color:green">successfully added ' . $email . ' to our database <p/>';
  73. }
  74. else{
  75. //echo '<p style="color:red;font-weight:bold;">unable to add ' . $email . ' to our database <p/>';
  76. }
  77.  
  78. $sql = "UPDATE emails
  79. SET partner_id = id
  80. WHERE emailaddress = partner_email";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement