0

trying to find the solution, please help. First of all find the code below.

when i remove the 'right variable' it's working fine. But i have to add the text of this div in every email. i have tried .text() and .html() both are not working. Please help me how to grab the text of a div in php mail function.

http://www.ankooverseas.com/select_university

user1812111
  • 83
  • 1
  • 1
  • 11
  • you will not be able to use `.html() .text()` on php.. use that on js. also your are passing `right` on ajax so get it using a `$_POST['right']` – Severino Lorilla Jr. Apr 21 '16 at 07:45
  • thanks, i think it's working. but i can't see the data in the email which was delivered to my email. output looks like Name: Contact: Email Id: Universities: – user1812111 Apr 21 '16 at 07:53

2 Answers2

2

I would make VarData an object, to make the encoding operations easier:

var VarData={studentName: student_name, studentContact: student_contact, studentEmail: student_email, right: right};

Then in your php code you shoudl be able to easily get the variables from $_POST:

$student_name=$_POST['studentName'];
$student_contact=$_POST['studentContact'];
$student_email=$_POST['studentEmail'];
$right=$_POST['right'];

Please note that $_POST is a php global variable created by the web server into the Php context and it contains the data submitted in a HTTP POST request. The variable is an array, having as keys the HTTP POST field names and as values the field values. As such, accessing this as $_POST['#right'] makes no sense, as there is not field called #right. What also doesn't make sense, as this is not jQuery, is the calll to $_POST['#right'].html() - there is no object method called .html() on arrays because a) they are not objects b) arrays don't necessaily contain html code, they are general language constructs.

The most likely reason why your code doesn't work is that because the content of your div is not url-encoded in the VarData string. Making VarData an object removes the need for you to encode data.

RedPoppy
  • 573
  • 4
  • 11
0

You cannot use jquery within php. if you want to POST the data you should set a hidden textarea with that data using jquery and you will be able to use it in the php script that processes the form. I assume hidden if you dont want the user to see the content in a textarea.

<textarea name="right" cols="20" rows="20" style="display:none;"></textarea> // the view

$right = $_POST['right'];// access that content from the textarea in your php file that processes the form
Jason Joslin
  • 1,154
  • 8
  • 23