Member
|
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> </p> <div align="center"> <table width="75%" border="0"> <tr> <td width="39%"> </td> <td width="61%"><div align="left"><strong>Personal details</strong></div></td> </tr> <tr> <td><div align="right"><strong> 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 |
Microbial member
|
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 |
Selfish Heathen
Join Date: May 2004
Location: Zone of Pain
|
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 |
Microbial member
|
Quote:
|
|
quote |
Selfish Heathen
Join Date: May 2004
Location: Zone of Pain
|
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 |
Member
|
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 |
Microbial member
|
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 |
Selfish Heathen
Join Date: May 2004
Location: Zone of Pain
|
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 |
Microbial member
|
Yeah, but your script is more robust than mine.
|
quote |
Microbial member
|
Quote:
|
|
quote |
Member
|
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 |
Microbial member
|
Hey, I'm in Australia too.
I'm not planning to go to bed for probably another 5 hours tho'. Damn thesis. |
quote |
Selfish Heathen
Join Date: May 2004
Location: Zone of Pain
|
Quote:
![]() |
|
quote |
Microbial member
|
Quote:
|
|
quote |
Member
Join Date: Oct 2005
|
Quote:
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 |
Selfish Heathen
Join Date: May 2004
Location: Zone of Pain
|
Huh! I didn't know that. I guess I've just been lucky all these years. Thanks for the information.
![]() |
quote |
Member
|
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 |
Selfish Heathen
Join Date: May 2004
Location: Zone of Pain
|
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 |
Member
|
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 |
Selfish Heathen
Join Date: May 2004
Location: Zone of Pain
|
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. ![]() 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 |
Veteran Member
Join Date: May 2004
Location: Minnesota
|
Is someone taking an econ class this semester?
|
quote |
Selfish Heathen
Join Date: May 2004
Location: Zone of Pain
|
No.
![]() 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 |
Member
Join Date: Oct 2005
|
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 |
|
Thread Tools | |
![]() |
||||
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 |