Jump to content

using javascript variables in php mail?


illuz1on

Recommended Posts

Hey,

 

I have a script that gets a whole bunch of values over a couple of pages, and this is how it output's at the moment.

 

function showValues(form){
var values = '';
var len = form.length - 1; //Leave off Submit Button
for(i=0; i<len; i++){
	if(form[i].id.indexOf("C")!=-1||form[i].id.indexOf("B")!=-1)//Skip Continue and Back Buttons
		continue;
	values += form[i].id;
	values += ': ';
	values += form[i].value;
	values += '\n';
}
alert(values);
}
[code]

Im trying to get these values to something I could use in a PHP Mail function, so I can let the owner of the site see what the user selected, in the email the mailer sends him.

Alternatively, if I could insert them into a database that would also be fine..

Any advice on how I would go about this?

Thanks
Chris

[/code]

Link to comment
https://forums.phpfreaks.com/topic/90709-using-javascript-variables-in-php-mail/
Share on other sites

Im not sure what you mean by "And"...

 

Well at the moment it brings up a box with all the id's and the values. I want to be able to use those values in a PHP mail function... but cant see how to?

 

 

function showValues(form){
var values = '';
var len = form.length - 1; //Leave off Submit Button
for(i=0; i<len; i++){
	if(form[i].id.indexOf("C")!=-1||form[i].id.indexOf("B")!=-1)//Skip Continue and Back Buttons
		continue;
	values += form[i].id;
	values += ': ';
	values += form[i].value;
	values += '\n';
}
alert(values);
}

 

 

You don't need javascript for this at all. In fact, unless you are trying an AJAX solution, you can't do what you are trying to with javascript.

 

What you need to do is submit the form to another page (set the "action" attribute in the <form> tag), then access each of the variables that the person has set using $_POST['variable_name'] in order to set the parts you need for your mail function.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.