Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. <?php
  2.  
  3. if(!empty($_POST)){
  4.  
  5.  
  6.  
  7. $username = 'username';
  8. $password = 'password';
  9. $server = '166.62.x.x';
  10.  
  11. // Create connection
  12. $conn = mysql_connect($server, $username, $password);
  13.  
  14. if(! $conn )
  15. {
  16. die('Could not connect: ' . mysql_error());
  17. }
  18.  
  19. $uploaddir = 'uploads/';
  20. $uploadfile = $uploaddir . basename($_FILES['uploaded_file']['name']);
  21.  
  22. if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $uploadfile)) {
  23. $msg = "File is valid, and was successfully uploaded.n";
  24. } else {
  25. $msg = "Possible file upload attack!n";
  26. }
  27.  
  28. $insert= "INSERT INTO careers (name, email, phone, apply, uploaded_file)
  29. VALUES ('" . $_POST['name'] . "', '" . $_POST['email'] . "', '" . $_POST['phone'] . "', '" . $_POST['apply'] . "', '" . $_FILES['uploaded_file']['name'] . "')";
  30. //print_r($insert);
  31.  
  32. mysql_select_db('ais_db');
  33.  
  34. //mysql_select_db('arpaninteractive');
  35.  
  36. $retval = mysql_query( $insert, $conn );
  37.  
  38. if(1){
  39. function SendCareerMail (){
  40. $url = 'https://api.sendgrid.com/';
  41. $user = 'ayush483';
  42. $pass = 'xxxx';
  43.  
  44. $name = $_REQUEST['name'];
  45. $email = $_REQUEST['email'];
  46. $phone = $_REQUEST['phone'];
  47. $apply = $_REQUEST['apply'];
  48.  
  49. $uploaddirmail = 'uploads/';
  50. $uploadfilemail = $uploaddirmail . basename($_FILES['uploaded_file']['name']);
  51. $file = file_get_contents($uploadfilemail, true);
  52.  
  53. $json_string = array(
  54.  
  55. 'to' => array(
  56. 'ayush@arpaninteractive.com'
  57. ),
  58. 'category' => 'Important'
  59. );
  60.  
  61. $params = array(
  62. 'api_user' => $user,
  63. 'api_key' => $pass,
  64. 'x-smtpapi' => json_encode($json_string),
  65. 'to' => 'ayush@arpaninteractive.com',
  66. 'subject' => 'Thanks for Contacting, We will get back to you shortly',
  67. 'html' => '
  68. Name: '.$name.' <br/>
  69. E-mail: '.$email.'<br/>
  70. Phone: '.$phone.'<br/>
  71. Message: '.$apply.'<br/>
  72. ',
  73. 'text' => 'Welcome Text',
  74. 'from' => 'ayush483@gmail.com','files['.$uploadfilemail.']' => '@'.$file.'/'.$uploadfilemail
  75. );
  76.  
  77. $request = $url.'api/mail.send.json';
  78. //echo "ayush";
  79.  
  80. // Generate curl request
  81. $session = curl_init($request);
  82. // Tell curl to use HTTP POST
  83. curl_setopt ($session, CURLOPT_POST, true);
  84. // Tell curl that this is the body of the POST
  85. curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
  86. // Tell curl not to return headers, but do return the response
  87. curl_setopt($session, CURLOPT_HEADER, false);
  88. // Tell PHP not to use SSLv3 (instead opting for TLS)
  89. curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
  90. curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  91.  
  92. // obtain response
  93. $response = curl_exec($session);
  94. curl_close($session);
  95.  
  96. // print everything out
  97. //print_r($response);
  98.  
  99. if($response){
  100. $msg = "Thank you for using our mail form";
  101. }else{
  102. $msg = "Mail sending failed.";
  103. }
  104. //echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
  105. //header('Location: index.php');
  106. // You can also use header('Location: thank_you.php'); to redirect to another page.
  107. // You cannot use header and echo together. It's one or the other.
  108. }
  109. SendCareerMail(); //calling the function
  110. }
  111.  
  112. if(! $retval )
  113. {
  114. die('Could not enter data: ' . mysql_error());
  115. }
  116. $url = "career-read-more.php?resp=suc & $msg";
  117. unset($insert);
  118. mysql_close($conn);
  119. header("Location:" . $url);
  120. }
  121. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement