Jump to content



Photo

Creating an HTML Contact Form

html

  • Please log in to reply
8 replies to this topic

#1 M_Lyons10

M_Lyons10

    Neowinian Senior

  • Joined: 21-October 08
  • Location: Pennsylvania

Posted 31 January 2013 - 18:52

Hi everyone. I don't work in HTML very often at all, but I am working on a simple website presently and wanted to add a contact form, but our hosting is Windows, so php is not an option. So I was wondering if I was able to create a simple contact page in html. I've never attempted to do so before, and after searching online didn't find a way that this has been accomplished, so I wanted to ask on here.

So, what suggestions would those that are much more familiar with HTML than I have? Any help is greatly appreciated.

Thanks Again,


#2 Uplift

Uplift

    Just below average Joe

  • Tech Issues Solved: 1
  • Joined: 07-May 04
  • Location: England

Posted 31 January 2013 - 20:14

As a php developer i can't help directly, but you can create the HTML part of the form the same way you would create any form, then instead of PHP it can probably be done in CGI or ASP?

#3 +Nik L

Nik L

    Where's my pants?

  • Tech Issues Solved: 1
  • Joined: 14-January 03

Posted 31 January 2013 - 20:24

You USED to be able to have the action attribute as a mailto. Not sure if it still works. It's less than impressive though...

#4 threetonesun

threetonesun

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 26-February 02

Posted 31 January 2013 - 20:36

I would, at the very least, run it through some Javascript validation and mail it from there. Unless you're ok with the possibility of perpetual spam and allowing an e-mail address to be out in the open.

#5 primexx

primexx

    Neowinian Senior

  • Tech Issues Solved: 6
  • Joined: 24-April 05

Posted 01 February 2013 - 09:15

there's no excuse to rely on the client to handle forms in this day and age. write a mailing script in whatever language your host does support.

#6 OP M_Lyons10

M_Lyons10

    Neowinian Senior

  • Joined: 21-October 08
  • Location: Pennsylvania

Posted 01 February 2013 - 14:40

there's no excuse to rely on the client to handle forms in this day and age. write a mailing script in whatever language your host does support.


Thanks everyone for your responses. I have windows hosting, so I could write something in C# as an example (That's what I use for desktop development).

I guess my question though would be how to do that... I know it's broad, but I've never done anything like that. Would I create the UI in the HTML document and then on Send button click somehow use the C# code? I'm very intrigued by your post, but I honestly don't understand how this would be accomplished. Like I said, I very infrequently do web work, so while sending an e-mail is no problem on the desktop, I am unsure of how to do that through an HTML page.

Thanks Again everyone for your help.

#7 Uplift

Uplift

    Just below average Joe

  • Tech Issues Solved: 1
  • Joined: 07-May 04
  • Location: England

Posted 01 February 2013 - 14:54

Why can't you use ASP?
http://www.123-reg.c...tact-form-2547/

#8 primexx

primexx

    Neowinian Senior

  • Tech Issues Solved: 6
  • Joined: 24-April 05

Posted 01 February 2013 - 23:40

Thanks everyone for your responses. I have windows hosting, so I could write something in C# as an example (That's what I use for desktop development).

I guess my question though would be how to do that... I know it's broad, but I've never done anything like that. Would I create the UI in the HTML document and then on Send button click somehow use the C# code? I'm very intrigued by your post, but I honestly don't understand how this would be accomplished. Like I said, I very infrequently do web work, so while sending an e-mail is no problem on the desktop, I am unsure of how to do that through an HTML page.

Thanks Again everyone for your help.


you'd do exactly the same as you would a PHP-based form. Have the HTML form POST to the server side script, and figure out how to read that POSTed data in the language of your choosing and process it from there.

#9 OP M_Lyons10

M_Lyons10

    Neowinian Senior

  • Joined: 21-October 08
  • Location: Pennsylvania

Posted 18 February 2013 - 16:52

you'd do exactly the same as you would a PHP-based form. Have the HTML form POST to the server side script, and figure out how to read that POSTed data in the language of your choosing and process it from there.


Thanks everyone for all of your help. I think I'm definitely on the right track (I actually wasn't aware of POST). I've never done anything like this before, just basic html pages...

Here's what I have. I found an online tool that generates this, which I thought was pretty handy.

html:
<!-- Website Contact Form Generator -->
<!-- http://www.tele-pro....s/contact_form/ -->
<!-- This script is free to use as long as you -->
<!-- retain the credit link -->

<form method="POST" action="/cgi-bin/contact.cgi">
Fields marked (*) are required

<p>Email From:* <br>
<input type="text" name="EmailFrom">
<p>Subject: <br>
<input type="text" name="Subject">
<p>Name:<br>
<input type="text" name="Name">
<p>Tel:<br>
<input type="text" name="Tel">
<p><input type="submit" name="submit" value="Submit">
</form>
<p>

<!-- Contact Form credit link -->
Created by <a target="_blank"
href="http://www.tele-pro...._form/">Contact
Form Generator</a>

CGI (I changed the email address for this post only):
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
print "Content-type: text/html \n\n";

# Website Contact Form Generator
# http://www.tele-pro....s/contact_form/
# This script is free to use as long as you
# retain the credit link

# get posted data into local variables
$input = new CGI;
$EmailFrom = $input->param('EmailFrom');
$EmailTo = "email\@mysite.com";
$Subject = $input->param('Subject');
$Name = $input->param('Name');
$Tel = $input->param('Tel');

# validation
$validationOK=true;
if ($EmailFrom eq '') {$validationOK=false;}
if ($validationOK eq false) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}

# prepare email body text
$Body .= "Name: ";
$Body .= "$Name";
$Body .= "\n";
$Body .= "Tel: ";
$Body .= "$Tel";
$Body .= "\n";

# send email
use Win32::OLE;
$ex = Win32::OLE->new('CDONTS.NewMail') or die "\nCDONTS error";
$ex->Send($EmailFrom,$EmailTo,$Subject,$Body);

# redirect to success page
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";

But the error I get is:
HTTP Error 404.0 - Not Found

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.


Which, O.K., that's no big deal, the post action is directing it to a file that's not there. But I've creating the cgi-bin directory, I've stuck the file in there, I've changed the path to another directory where I put the file. No matter what I do it can't find this file. So, I was wondering if anyone sees something that I'm missing... I figured this would work if the file was where it should be... ?

Thanks Again for all of the help. I really appreciate it.



Click here to login or here to register to remove this ad, it's free!