[Javascript] sending of variables via email...

Jamesjackson73 at aol.com Jamesjackson73 at aol.com
Tue Jan 21 10:36:47 CST 2003


Javascript/php/html experts... your'e bound to know how to...

experts
I have a form in which Ive used the Date() function to create a unique numbering system which is different everytime a user access's a page. but then (along with other form fields - not shown) the contents of the fields would entered would shown when submit was pressed AND emailed using php, but I can't seem to transfer the complete value of 'formNumber'. The HTML & HTML with PHP code is below. Please help!
Regards jimjacksonis at hotmail.com


***HTML***
<html>
<head>
<title>form2mail</title>
</head>
<body>
<form name="form2mail" method="post" action="http://www.uni.ac.uk/php-cgiwrap//form2mail.php3">

<script language="JavaScript1.2">
<!-- Gets now date&time -->
var time=new Date();
var date=time.getDate();
if (date<10)
date="0"+date
var month=time.getMonth() +1;
if (month<10)
month="0"+month
var hour=time.getHours();
if (hour<10)
hour="0"+hour
var minute=time.getMinutes();
if (minute<10)
minute="0"+minute
var second=time.getSeconds();
if (second<10)
second="0"+second
formNumber = (date + "" + month + "" + hour + "" + minute + "" + second);
document.write(formNumber); // writes number to screen - works fine!
// End -->
</script>
        <input type="hidden" name="formNumber" id="formNumber">

        <input name="submit" type="submit" id="submit" value="Submit Form">
</form>
</body>
</html>

***PHP Script***
<html>
<head>
<title>Form-2-mail Submission</title>
</head>
<body>
<?php
  $formcontent = "";
  $formcontent .= "Form Number: $formNumber\n"; //Should take value of formNumber variable
  $toaddress = "myemailaddress at aol.com";
  $subjectline = "Form completed by me";
  $headers = "From: sender\n";
  mail( $toaddress, $subjectline, $formcontent, $headers);

  echo "
  <b>Thank you, The following email has been sent to $toaddress:</b>
  <pre>$formcontent</pre>
  "; // end echo statement
?> // end php
</body>
</html>



More information about the Javascript mailing list