User Name
Password

Register Members List Calendar Search FAQ Posting Guidelines
HTML help
Thread Tools
cyrusmekon
Member
 
Join Date: Aug 2004
Location: Melbourne
Send a message via AIM to cyrusmekon Send a message via Yahoo to cyrusmekon  
2005-10-17, 12:08

Hi guys maybe one of you would be so kind to help.

First off i know very basic HTML and have been asked to make a "form" for our webpage. It does not need to be secure etc

I have made the form but would like the form emailed to me automatically when the user presses the submit button. I see you can send an email but this requires you to open up a mail client.

Can you do this task automatically. Like i say i know very basic HTML, searched the web a bit and found nothing obvious. Its 3AM what is at this time.

If anyone can help, lead me in the right direction that would be awsome.

I have attached the code i have done so far.

Regards, Cyrus.


<html>
<head>
<title>Register</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body bgcolor="ffffff">

<center>
<table border=0 width=75% height=80% cellpadding=10 cellspacing=0>
<tr>
<td align=left valign=top> <p><IMG SRC="../titles/register.jpg" width="280" height="49" border=0></p>
<p>&nbsp;</p>
<div align="center">
<table width="75%" border="0">
<tr>
<td width="39%">&nbsp;</td>
<td width="61%"><div align="left"><strong>Personal details</strong></div></td>
</tr>
<tr>
<td><div align="right"><strong>&nbsp;Name*</strong></div></td>
<td><form name="form2" method="post" action="">
<label>
<input type="text" name="textfield7">
</label>
</form></td>
</tr>
<tr>
<td><div align="right"><strong>Street Address:</strong></div></td>
<td><form name="form3" method="post" action="">
<label>
<input type="text" name="textfield8">
</label>
</form></td>
</tr>
<tr>
<td><div align="right"><strong>Address (Cont)</strong>
<label> </label>
</div></td>
<td><form name="form4" method="post" action="">
<label>
<input type="text" name="textfield9">
</label>
</form></td>
</tr>
<tr>
<td><div align="right"><strong>Country
<label> </label>
</strong>
<label></label>
</div></td>
<td><form name="form6" method="post" action="">
<label>
<input type="text" name="textfield11">
</label>
</form></td>
</tr>
<tr>
<td><div align="right"><strong>Tel #
<label> </label>
</strong></div></td>
<td><form name="form7" method="post" action="">
<label>
<input type="text" name="textfield12">
</label>
</form></td>
</tr>
<tr>
<td><div align="right"><strong>Email*
<label> </label>
</strong>
<label></label>
</div></td>
<td><form name="form5" method="post" action="">
<label>
<input type="text" name="textfield10">
</label>
</form></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</div>
<p>*Required fields</p>
</TD>
</tr>



<tr><td align=left valign=middle bgcolor="9ea4ed">
<p><br>
<a href="../index.html"><IMG SRC="../titles/back.jpg" border=0 align=right></a>
</td></tr></table>
</center>
</body></html>
  quote
staph
Microbial member
 
Join Date: May 2004
Send a message via AIM to staph  
2005-10-17, 12:14

Do you have php on your web server? You could build a very simple form handler to send the mail with php's built-in email functionality.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-10-17, 12:14

Instead of action="" try action="mailto:youraddress@yourdomain.com" in the form tag.

Also, you only want one opening form tag at the beginning before your inputs and one closing form tag at the end after your submit button.

For example:

<form method="post" action="mailto:name@server.com">
<input type="text" name="name" />
<input type="text" name="address1" />
<input type="text" name="address1" />
<input type="text" name="country" />
<input type="text" name="telephone" />
<input type="text" name="email" />
<input type="submit" name="Submit" value="Submit" />
</form>

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote
staph
Microbial member
 
Join Date: May 2004
Send a message via AIM to staph  
2005-10-17, 12:16

Quote:
Originally Posted by Brad
Instead of action="" try action="mailto:youraddress@yourdomain.com" in the form tag.
Wouldn't that open up the mail client like he didn't want?
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-10-17, 12:20

Yeah. *scratches head* Hmm... I know there was a way to do this. It's been a long time, but I used to write forms that did this.
  quote
cyrusmekon
Member
 
Join Date: Aug 2004
Location: Melbourne
Send a message via AIM to cyrusmekon Send a message via Yahoo to cyrusmekon  
2005-10-17, 12:22

Thanks for the replies

Staph you are right, when the user presses the submit button i would like everything to be automatic, that is all input fields emaild to a given email address without a mail client being involved.


I am positive we have php on our server. How would you build such a form from the built in email functionality?

Sorry im a bit out my depth here but would love to learn.

Appreciate your time.
  quote
staph
Microbial member
 
Join Date: May 2004
Send a message via AIM to staph  
2005-10-17, 12:27

Right, here's some sample code on how to do a simple email handler. Make the action of the submit button a page with this code in it somewhere.

You'll want to have a line lie $string = "POST['string']"; for each of your strings, with the name in the square brackets, and a unique variable name ($string for each). The next line ($uberstring = $string . $string2) concatenates them together with a newline in between.

I'm not a php person normally, so if I've done anything egregiously wrong, please point it out!

[php]<?php

$uberstring = $string . "\n" . $string2;
// concat your strings with the . symbol
// between each string to be concatenated

$to = 'nobody@example.com';
$subject = 'the subject';
$message = $uberstring;
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers); //send the mail!

?>[/php]

BTW: this code sample is largely from the PHP mail documentation page, which can be found here

Edit2: PHP syntax highlighting is way cool!

Last edited by staph : 2005-10-17 at 12:50.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-10-17, 12:32

PHP? Oh, that makes it EASY.

1. Be sure the fields have unique names like in my example.
2. Create a file called something.php and make it the target of that form.
3. Make something.php look like this:

[php]<html>
<head>
<title>Thank you!</title>
</head>
<body>

<p>This is a confirmation page... blah blah blah...</p>

<?php
$to = "you@domain.com";
$subject = "Form Submission";
$body = "Form Results: \n\n";
$body = $body."Real Name: $name \n";
$body = $body."Address Line 1: $address1 \n";
$body = $body."Address Line 2: $address2 \n";
$body = $body."Country: $country \n";
$body = $body."Telephone Number: $phone \n";
$body = $body."Email Address: $email \n";
if (mail($to, $subject, $body))
{ ?>

<p>Message successfully sent!</p>
<p>Click <a href="somewhere.html">here</a> to return to the main page</p>.

<?php} else {?>

<p>Message delivery failed...</p>
<p>Click <a href="somewhere.html">here</a> to return to the main page</p>.

<?php }?>

</body>
</html>
[/php]

Note that $address1 will correspond to the field whose name was address1. You can add or change those as needed.

edit: yeah, staph's on the right track. Curse my slow fingers.

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote
staph
Microbial member
 
Join Date: May 2004
Send a message via AIM to staph  
2005-10-17, 12:37

Yeah, but your script is more robust than mine.
  quote
staph
Microbial member
 
Join Date: May 2004
Send a message via AIM to staph  
2005-10-17, 12:39

Quote:
Originally Posted by Brad
Note that $address1 will correspond to the field whose name was address1. You can add or change those as needed.
So you don't need to explicitly get them from the POST query? Nifty!!
  quote
cyrusmekon
Member
 
Join Date: Aug 2004
Location: Melbourne
Send a message via AIM to cyrusmekon Send a message via Yahoo to cyrusmekon  
2005-10-17, 12:39

Wow you guys are quick

Its 3.37am here (Australia).

Im going to give this a go when i wake up in the morning.

Thank you and i will aknowledge you guys (in the code)
  quote
staph
Microbial member
 
Join Date: May 2004
Send a message via AIM to staph  
2005-10-17, 12:40

Hey, I'm in Australia too.

I'm not planning to go to bed for probably another 5 hours tho'. Damn thesis.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-10-17, 12:41

Quote:
Originally Posted by staph
So you don't need to explicitly get them from the POST query? Nifty!!
Nope! At least, I don't and I've never had a problem with it.
  quote
staph
Microbial member
 
Join Date: May 2004
Send a message via AIM to staph  
2005-10-17, 12:45

Quote:
Originally Posted by Brad
Nope! At least, I don't and I've never had a problem with it.
God, that's almost reason enough to give up on on Perl for CGI.
  quote
deuce868
Member
 
Join Date: Oct 2005
 
2005-10-17, 13:26

Quote:
Originally Posted by Brad
Nope! At least, I don't and I've never had a problem with it.
That only works if the server has REGISTER_GLOBALS turned on. Many hosts have that turned off these days and consider it a security risk.

As someone that writes code, it's so much better to put $_POST/$_GET because then at least when someone else reads the form they can tell where in the world this $address variable comes from.

See this for more info:
http://us3.php.net/manual/en/security.globals.php
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-10-17, 19:47

Huh! I didn't know that. I guess I've just been lucky all these years. Thanks for the information.
  quote
cyrusmekon
Member
 
Join Date: Aug 2004
Location: Melbourne
Send a message via AIM to cyrusmekon Send a message via Yahoo to cyrusmekon  
2005-10-17, 21:46

Hi well iv wokn from the land of the dead

I have been doing a bit of searching

http://tools4php.com/form-wizard/index.html

Does this look like a waste of money? It seems very appealing to me. It will do what i want and quickly.

The autoresponder etc would be a nice touch. WOrth $19.95.

Remember i have NO experiance with this at all, just basic HTML.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-10-17, 21:49

Well, it's Windows-only. So, that may answer your question immediately.

I've never used that kind of code-generating tool; so, I can't vouch for its usefulness.

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote
cyrusmekon
Member
 
Join Date: Aug 2004
Location: Melbourne
Send a message via AIM to cyrusmekon Send a message via Yahoo to cyrusmekon  
2005-10-17, 21:55

Windows based is not a problem, im at work slowly converting the masses. Hey i have added 5 new Mac users since i got here.

Yes the generator is appelaing just for the fact i may not have to deal with script, but 19.95 thats what im trying to decide.

Any feedback from anyone using a generator would be greatfull.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-10-17, 22:11

Well, look at it this way:

How much do you get paid per hour? Divide $19.95 by that number to see how much it's really "worth" to you in work-hours. If you get paid $20 an hour at your job, that means it's worth one hour of your time. You've probably spent more than that much time researching these options; so, it could have more than paid for itself by now!

That's one of the best ways to gauge if any software title is worth buying versus inventing/writing your own implementation that does the same task. Actually, a good way of gauging the value of any purchase is by comparing it to how much you have to work to pay for it.

Of course, you also need to weigh another important factor: would you want to learn PHP enough so you could understand how the script works (or write your own) and customize it in the future? Say it takes 10 hours to learn and try out the PHP features that you'd need for this form e-mailer. At the $20/hr wage mentioned above, that's a $200 "cost" to get the job done. Now, if learning PHP would be a waste of your time and you never plan to use it again, purchasing the product is the better option. If you think you would benefit in the future by learning PHP now, then that $200 "cost" is significantly offset and may be better than just buying the product.

Did I answer your question with more questions?

Well, I hope it helps a little.

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote
LudwigVan
Veteran Member
 
Join Date: May 2004
Location: Minnesota
 
2005-10-18, 01:04

Is someone taking an econ class this semester?
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-10-18, 01:16

No. Though, I did have one two (or was it three?) years ago.

I recently had to explain this whole "value of software" to someone in the Real World™ and it was all still fresh in my mind, I guess.

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote
deuce868
Member
 
Join Date: Oct 2005
 
2005-10-18, 06:05

the problem with generators is the first time you need something that doesn't have a checkbox in the generator you're back to square one needing to learn how to do it. Not only that, but you're trusting the generator to build something secure, scalable, and when you have issues with it you still have to learn it and figure out what's wrong.

If it works for you cool, but I've never been a fan. I started out with dreamweaver writing my php for me until I had to make my pages do things DW didn't support and then I just had to learn it all and write it by hand anyway. It's usually better that way.
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Post Reply

Forum Jump
Thread Tools
Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML question... Wickers Programmer's Nook 16 2019-07-29 22:46
Navigating an HTML form on a Mac sildani Genius Bar 3 2005-09-29 20:22
What is the difference between HTML and XHTML? Phoenix Genius Bar 7 2005-03-25 05:01
Mail.app WON'T send animated GIFs drewprops Genius Bar 7 2005-03-07 23:18
XML to HTML via CSV?!?? scratt Programmer's Nook 0 2005-02-14 11:56


« Previous Thread | Next Thread »

All times are GMT -5. The time now is 08:49.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova