Now my problem is to get the referenceid from Url.
Code: Select all
<script src="jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function (e){
$("#frmEnquiry").on('submit',(function(e){
e.preventDefault();
$('#loader-icon').show();
var valid;
valid = validateContact();
if(valid) {
$.ajax({
url: "mail-send.php?id='.$_GET['referenceid'].'",
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData:false,
success: function(data){
$("#mail-status").html(data);
$('#loader-icon').hide();
},
error: function(){}
});
}
}));
function validateContact() {
var valid = true;
$(".demoInputBox").css('background-color','');
$(".info").html('');
$("#userName").removeClass("invalid");
$("#userEmail").removeClass("invalid");
$("#subject").removeClass("invalid");
$("#content").removeClass("invalid");
if(!$("#userName").val()) {
$("#userName").addClass("invalid");
$("#userName").attr("title","Required");
valid = false;
}
if(!$("#userEmail").val()) {
$("#userEmail").addClass("invalid");
$("#userEmail").attr("title","Required");
valid = false;
}
if(!$("#userEmail").val().match(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/)) {
$("#userEmail").addClass("invalid");
$("#userEmail").attr("title","Invalid Email");
valid = false;
}
if(!$("#subject").val()) {
$("#subject").addClass("invalid");
$("#subject").attr("title","Required");
valid = false;
}
if(!$("#content").val()) {
$("#content").addClass("invalid");
$("#content").attr("title","Required");
valid = false;
}
return valid;
}
});
</script>
After this maill-send page is loading into the same page
but their I can`t find out how to get the referenceid
Code: Select all
<?php
$referenceid = isset($_GET['referenceid']) ?(int) $_GET['referenceid'] :'';
//your code ..
?>
<script>
var id_usr1 ='<?php echo $referenceid; ?>';
</script>
<?php
include('connection.php');
$sql=mysqli_query($conn,"SELECT * FROM `report` WHERE reference_id_2='$referenceid' ");
$profile=mysqli_fetch_assoc($sql);
?>
<?php
require('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->Username = "YOUR USER_NAME";
$mail->Password = "YOUR PASSWORD";
$mail->Host = "YOUR HOST";
$mail->Mailer = "smtp.kpnmail.nl";
$mail->SetFrom($_POST["userEmail"], $_POST["userName"]);
$mail->AddReplyTo($_POST["userEmail"], $_POST["userName"]);
$mail->AddAddress("jan-molendijk@live.nl");
$mail->Subject = $_POST["subject"];
$mail->WordWrap = 80;
$mail->MsgHTML($_POST["content"]);
foreach ($_FILES["attachment"]["name"] as $k => $v) {
$mail->AddAttachment( $_FILES["attachment"]["tmp_name"][$k], $_FILES["attachment"]["name"][$k] );
}
$mail->IsHTML(true);
if(!$mail->Send()) {
echo "<p class='error'>Problem in Sending Mail.</p>";
} else {
echo "
okok '. $profile[userName] .'
<form action='' method='post'>
First Name: <input type='text' name='first_name'><br>
Last Name: <input type='text' name='last_name'><br>
Email: <input type='text' value=''. $profile[userName] .'' name='email'><br>
Message:<br><textarea rows='5' name='message' cols='30'></textarea><br>
<input type='submit' name='submit' value='Submit'>
</form>
";
}
?>