Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!empty($_POST)){
- $username = 'username';
- $password = 'password';
- $server = '166.62.x.x';
- // Create connection
- $conn = mysql_connect($server, $username, $password);
- if(! $conn )
- {
- die('Could not connect: ' . mysql_error());
- }
- $uploaddir = 'uploads/';
- $uploadfile = $uploaddir . basename($_FILES['uploaded_file']['name']);
- if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $uploadfile)) {
- $msg = "File is valid, and was successfully uploaded.n";
- } else {
- $msg = "Possible file upload attack!n";
- }
- $insert= "INSERT INTO careers (name, email, phone, apply, uploaded_file)
- VALUES ('" . $_POST['name'] . "', '" . $_POST['email'] . "', '" . $_POST['phone'] . "', '" . $_POST['apply'] . "', '" . $_FILES['uploaded_file']['name'] . "')";
- //print_r($insert);
- mysql_select_db('ais_db');
- //mysql_select_db('arpaninteractive');
- $retval = mysql_query( $insert, $conn );
- if(1){
- function SendCareerMail (){
- $url = 'https://api.sendgrid.com/';
- $user = 'ayush483';
- $pass = 'xxxx';
- $name = $_REQUEST['name'];
- $email = $_REQUEST['email'];
- $phone = $_REQUEST['phone'];
- $apply = $_REQUEST['apply'];
- $uploaddirmail = 'uploads/';
- $uploadfilemail = $uploaddirmail . basename($_FILES['uploaded_file']['name']);
- $file = file_get_contents($uploadfilemail, true);
- $json_string = array(
- 'to' => array(
- 'ayush@arpaninteractive.com'
- ),
- 'category' => 'Important'
- );
- $params = array(
- 'api_user' => $user,
- 'api_key' => $pass,
- 'x-smtpapi' => json_encode($json_string),
- 'to' => 'ayush@arpaninteractive.com',
- 'subject' => 'Thanks for Contacting, We will get back to you shortly',
- 'html' => '
- Name: '.$name.' <br/>
- E-mail: '.$email.'<br/>
- Phone: '.$phone.'<br/>
- Message: '.$apply.'<br/>
- ',
- 'text' => 'Welcome Text',
- 'from' => 'ayush483@gmail.com','files['.$uploadfilemail.']' => '@'.$file.'/'.$uploadfilemail
- );
- $request = $url.'api/mail.send.json';
- //echo "ayush";
- // Generate curl request
- $session = curl_init($request);
- // Tell curl to use HTTP POST
- curl_setopt ($session, CURLOPT_POST, true);
- // Tell curl that this is the body of the POST
- curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
- // Tell curl not to return headers, but do return the response
- curl_setopt($session, CURLOPT_HEADER, false);
- // Tell PHP not to use SSLv3 (instead opting for TLS)
- curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
- curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
- // obtain response
- $response = curl_exec($session);
- curl_close($session);
- // print everything out
- //print_r($response);
- if($response){
- $msg = "Thank you for using our mail form";
- }else{
- $msg = "Mail sending failed.";
- }
- //echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
- //header('Location: index.php');
- // You can also use header('Location: thank_you.php'); to redirect to another page.
- // You cannot use header and echo together. It's one or the other.
- }
- SendCareerMail(); //calling the function
- }
- if(! $retval )
- {
- die('Could not enter data: ' . mysql_error());
- }
- $url = "career-read-more.php?resp=suc & $msg";
- unset($insert);
- mysql_close($conn);
- header("Location:" . $url);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement