What's up?
The issue is that I would like to create a form that users will fill with:
- their identification (name and e-mail)
- the destination e-mail where to send the result of calculation
- the parameters of calculation
I would not like users to see result of calculation on website, but only the destination e-mail owner.
Details are below.
What I have
I have a free webhosting that supports PHP, but it is very limited (I cannot install third party components nor send mail via mail
function nor read/edit php.ini
).
I also know a free Captcha solution.
Test #1
My first try was to create a form like that on index.htm
:
<html><head></head><body>
<form method="post" name="calc" action="go.php">
<table border="1">
<tr>
<td><label for="name">Your name</label></td>
<td><label for="email">Your e-mail</label></td>
<td><label for="email_result">The e-mail to send the result</label></td>
</tr>
<tr>
<td><input text="text" name="name"></td>
<td><input text="text" name="email"></td>
<td><input text="text" name="email_result"></td>
</tr>
<tr>
<td colspan="3">Data</td>
</tr>
<td colspan="3">
sin(<input text="text" name="A">) +<br>
cos(<input text="text" name="B">) +<br>
<input text="text" name="C"><br>
</td>
</tr>
<tr>
<td colspan="3"><input text="Go!" name="go" type="submit"></td>
</tr>
</table>
</form>
</body></html>
Below, the go.php
(I hide validation code):
$name = $_POST['name'];
$email = $_POST['email'];
$email_result = $_POST['email_result'];
$A = $_POST['A'];
$B = $_POST['B'];
$C = $_POST['C'];
$subject = "Calc";
$body = "Hello!\n\nThe result is bellow\n\n";
$body .= (sin(A)+cos(B)+C));
$header = "From: $email\r\n";
mail($email, $subject, $body, $header);
But, as said, although "Sent!" message is displayed, no e-mail is sent, but I know that the calculations are made (I can see it debugging).
Test #2
I then search for another way to send message and I found a Captcha service - a free on too ;). The new index.htm
:
<html><head></head><body>
<!-- Code for captcha -->
<form action="http://www.SnapHost.com/captcha/send.aspx" method="post" id="myform">
<input type="hidden" id="skip_WhereToSend" name="skip_WhereToSend" value="my@email.com" />
<input type="hidden" id="skip_Subject" name="skip_Subject" value="A test subject!!!" />
<input type="hidden" id="skip_WhereToReturn" name="skip_WhereToReturn" value="www.my.site.com/success.htm" />
<input type="hidden" id="skip_SnapHostID" name="skip_SnapHostID" value="some_id" />
<!-- Form -->
<form method="post" name="calc" action="go.php">
<table border="1">
<tr>
<td><label for="name">Your name</label></td>
<td><label for="email">Your e-mail</label></td>
<td><label for="email_result">The e-mail to send the result</label></td>
</tr>
<tr>
<td><input text="text" name="name"></td>
<td><input text="text" name="email"></td>
<td><input text="text" name="email_result"></td>
</tr>
<tr>
<td colspan="3">Data</td>
</tr>
<tr>
<td colspan="3">
sin(<input text="text" name="A">) +<br>
cos(<input text="text" name="B">) +<br>
<input text="text" name="C"><br>
</td>
</tr>
<tr>
<td colspan="3">
<!-- Code for captcha -->
<table cellspacing="0" border="0" cellpadding="8"
style="background-color:#ffcc66;">
<tr><td colspan="2" style="padding-bottom:1px;">
<a href="http://www.snaphost.com/captcha/ReadyForms/ContactUsExtendedForm.aspx" alt="online contact forms" title="online contact forms" >online contact forms</a></td></tr>
<tr valign="bottom"><td>
<a href="#" onclick="return ReloadCaptchaImage('CaptchaImage');"><span style="font-size:12px;">reload image</span></a><br />
<a href="http://www.snaphost.com/captcha/"><img id="CaptchaImage"
alt="captcha validation" style="border-width:0px;"
title="captcha validation"
src="http://www.SnapHost.com/captcha/CaptchaImage.aspx?id=some_id" /></a>
</td><td> <br /><i>Enter Captcha code</i><br />
<input id="skip_CaptchaCode" name="skip_CaptchaCode" type="text"
style="width:130px; height:48px; font-size:38px;" maxlength="6" /><br />
</td></tr></table>
<script type="text/javascript">
function ReloadCaptchaImage(captchaImageId) {
var obj = document.getElementById(captchaImageId);
var src = obj.src;
var date = new Date();
var pos = src.indexOf('&rad=');
if (pos >= 0) { src = src.substr(0, pos); }
obj.src = src + '&rad=' + date.getTime();
return false; }
</script>
<!-- Send button -->
</td>
</tr>
<tr>
<td colspan="3"><input text="Go!" name="go" type="submit"></td>
</tr>
</table>
</form>
</body></html>
So I can send e-mail to me with filled data on form, BUT with this way I cannot calculate sin(A)+cos(B)+C
!.