I am using custom email and form in my wordpress site.
Thing is in form there are 2 radio buttons :
- English
- Chinese
Other fields are normal.
I have 2 PDF uploaded to server for both above languages. What I want is to send use PDF link in email based on language selection in form.
I am trying but it is sending always same PDF link.
Code to check data and send in email :
if(isset($_POST['submit']) && isset($_POST['language1'])){
$clname=$_POST['clname'];
$clsurname=$_POST['clsurname'];
$clemail=$_POST['clemail'];
$radio = $_POST['language1'];
$fileatt1 = "http://example.com/english.pdf";
$fileatttype = "application/pdf";
$fileattname = "newname.pdf"; //name that you want to use to send or you can use the same name
$headers="From: ". $clname .' <'. $clemail .'>' . "\r\n";
$mail = get_option('admin_email');
$subject = "Testing";
$message="Name:".$clname.' '.$clsurname.'\n\n
Email:'.$clemail.'\n\n Radiovalue:'.$radio.'\n'. $fileatt;
wp_mail($mail,$subject,$message,$headers);
$emailsent= true;
}
Form Code
<div class="overflow-hidden">
<form class="text-center" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<div class="col-md-6">
<p class="tns">First Name *:</p>
<input type="text" name="clname" placeholder="First Name" required />
</div>
<div class="col-md-6">
<p class="tns">Last Name *:</p>
<input type="text" name="clsurname" placeholder="Last Name" required />
<input type="radio" name="language1" value="English">English
<input type="radio" name="language2" value="Chinese">Chinese </div>
</div>
<hr>
</div>
<div class="overflow-hidden">
<div class="col-sm-6 col-sm-offset-3">
<input type="submit" name="submit" value="submit" />
</div>
</div>
</form>
I have tried to put another PDF link in ELSE condition but that is not working. I have also tried by put 2 different if conditions but that is also not working for me.