@TMD
Can you post the code? Javascript & PHP so we can see the problem!
LastMitch
Industrious Poster
4,155 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
@TMD
Here is more or less my code (I cut out other parts since it is doing the same thing. What I am trying to do is get the variables that I created in the javascript section and using php email it to a personal user, but I am unsure how to call the variables in the php section from the javascript section.
I'm not familiar with javascript! But can you show the variable so I can see the issue? Plus in the future when you paste your code please used "Code" on text editor so it will be highlight in blue!
LastMitch
Industrious Poster
4,155 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
Is there any reason that you implemented the functionality in javascript? You could probably do the same processing with php and just mail the values. But if you really want to use javascript for processing then you will have to use ajax approach - a javascript function that passes values to a php file that will send the mail.
http://www.w3schools.com/ajax/default.asp
broj1
Nearly a Posting Virtuoso
1,211 posts since Jan 2011
Reputation Points: 167
Solved Threads: 164
Skill Endorsements: 13
@TMD
Do you have a database? If so what is the php file name?
If you don't have a database then I would suggest to used ajax.
In order to pass a varible you need to $_GET[] or $_POST[] function
LastMitch
Industrious Poster
4,155 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
A note on using script tags: a <script> tag is, as far as I know, used for scripts that browser executes (javascript, vbscript...). For server side scripts use <? ?> tags which for PHP is:
<?php
// PHP code here
?>
or in your example:
<html>
<?php
$email = "personal email addres" . ",";
$email .= $HTTP_POST_VARS['mailme'];
$subject = "Attack";
$data .= "Air 1: " . $HTTP_POST_VARS['air1'] . "n";
$data .= "Air 2: " . $HTTP_POST_VARS['air2'] . "n";
$data .= "Multiair: " . $HTTP_POST_VARS['multiair'] . "n";
$data .= "Cc: " . $HTTP_POST_VARS['mailme'] . "nn";
mail($email, $subject, $data, "From: myemailaddress");
}
?>
<script type="text/javascript">
function randInt(min, max) {
...
The language attribute in script tag is deprecated in HTML 4.01. Use only <script type="text/javascript">
broj1
Nearly a Posting Virtuoso
1,211 posts since Jan 2011
Reputation Points: 167
Solved Threads: 164
Skill Endorsements: 13
It's me again. Sory to post in pieces but I noticed another issue. Do not use $HTTP_POST_VARS array since it is deprecated and will be at some stage removed form PHP. Use $_POST array which is basically the same for your purpose.
broj1
Nearly a Posting Virtuoso
1,211 posts since Jan 2011
Reputation Points: 167
Solved Threads: 164
Skill Endorsements: 13