[Javascript] sending of variables via email...(makes more sense)

Jamesjackson73 at aol.com Jamesjackson73 at aol.com
Tue Jan 21 10:49:27 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 below) the contents of the fields entered would be shown when submit was pressed i.e. you entered... etc 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***form2.html***
<html>
<head>
<title>form2</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***form2mail.php3***
<html>
<head>
<title>form2mail</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