kargrafx
11-15-2006, 08:22 AM
Okay, I was mislead as to what serverside language(s) were available when I first started asking about this; so I have posted first in javascript (thinking none were available) and then in CGI/Perl (thinking PHP was not available). I now know the truth, and would prefer a PHP solution. I apologize for cross-posting the request, it was not intentional...
I have a friend who wants to collect email addresses from visitors to his website. He really isn't looking for security, but is more interested in collecting emails and simple contact information. Is there an easy way to have a short form which collects that info, then sends a password which they can use to log in?
specifically, I would like the following to occur...
>A form is filled out, requiring four fields, "Name", "Email", "Phone Number", and an "Opt-In/Out" checkbox.
>The user submits the form, and two emails are sent.
->One is sent to (admin@site.com) with the form field info.
->The other is sent to the address from form field 'Email', and is a pre-written email with a password to access the site.
So I start with a simple form...
<form method='post' action='<?php echo $PHP_SELF;?>'>
Name:<input type='text' size='20' name='name'><br />
Email:<input type='text' size='20' name='email'><br />
Phone Number:<input type='text' size='20' name='phone'><br />
By selecting this box you are signing up for our email list.<br />
Yes, keep me notified!:<input type='checkbox' value='optin' name='optin'><br />
<input type="submit" name="submit" value="submit">
</form>
I then create the PHP to parse the form...
<?php
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$optin = $_REQUEST['optin'];
$body = $name./n.$email./n.$phone./n.$optin
mail ('admin@site.com', 'new registration', $body)
mail ($email, 'Password', 'The password for www.site.com is password.')
?>
I then tied it together as follows...
<?php
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$optin = $_REQUEST['optin'];
$body = $name./n.$email./n.$phone./n.$optin
if (!isset($_REQUEST['submit'])) {
>?
<html><head></head><body>
<form method='post' action='<?php echo $PHP_SELF;?>'>
Name:<input type='text' size='20' name='name'><br />
Email:<input type='text' size='20' name='email'><br />
Phone Number:<input type='text' size='20' name='phone'><br />
By selecting this box you are signing up for our email list.<br />
Yes, keep me notified!:<input type='checkbox' value='optin' name='optin'><br />
<input type="submit" name="submit" value="submit">
</form></body>
<?
} else {
mail ('admin@site.com', 'new registration', $body)
mail ($email, 'Password', 'The password for www.site.com is password.')
?>
<html><head></head><body>
Thank you for registering, you will receive a password in your email shortly.
</body>
<?
}
?>
I know it is very crude, but I want to start as simple as possible as the entire site will be redesigned in a short time. The above does not seem to work for me, though; it only returns a blank webpage (source below). I tested a basic php mail test, so I know it works.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>
for example, mail ('me@site.com', 'test', 'test message') sent the email with subject 'test' and body 'test message'.
So obviously, even as simple as I tried to keep it, I screwed up somewhere. Any help?
I have a friend who wants to collect email addresses from visitors to his website. He really isn't looking for security, but is more interested in collecting emails and simple contact information. Is there an easy way to have a short form which collects that info, then sends a password which they can use to log in?
specifically, I would like the following to occur...
>A form is filled out, requiring four fields, "Name", "Email", "Phone Number", and an "Opt-In/Out" checkbox.
>The user submits the form, and two emails are sent.
->One is sent to (admin@site.com) with the form field info.
->The other is sent to the address from form field 'Email', and is a pre-written email with a password to access the site.
So I start with a simple form...
<form method='post' action='<?php echo $PHP_SELF;?>'>
Name:<input type='text' size='20' name='name'><br />
Email:<input type='text' size='20' name='email'><br />
Phone Number:<input type='text' size='20' name='phone'><br />
By selecting this box you are signing up for our email list.<br />
Yes, keep me notified!:<input type='checkbox' value='optin' name='optin'><br />
<input type="submit" name="submit" value="submit">
</form>
I then create the PHP to parse the form...
<?php
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$optin = $_REQUEST['optin'];
$body = $name./n.$email./n.$phone./n.$optin
mail ('admin@site.com', 'new registration', $body)
mail ($email, 'Password', 'The password for www.site.com is password.')
?>
I then tied it together as follows...
<?php
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$optin = $_REQUEST['optin'];
$body = $name./n.$email./n.$phone./n.$optin
if (!isset($_REQUEST['submit'])) {
>?
<html><head></head><body>
<form method='post' action='<?php echo $PHP_SELF;?>'>
Name:<input type='text' size='20' name='name'><br />
Email:<input type='text' size='20' name='email'><br />
Phone Number:<input type='text' size='20' name='phone'><br />
By selecting this box you are signing up for our email list.<br />
Yes, keep me notified!:<input type='checkbox' value='optin' name='optin'><br />
<input type="submit" name="submit" value="submit">
</form></body>
<?
} else {
mail ('admin@site.com', 'new registration', $body)
mail ($email, 'Password', 'The password for www.site.com is password.')
?>
<html><head></head><body>
Thank you for registering, you will receive a password in your email shortly.
</body>
<?
}
?>
I know it is very crude, but I want to start as simple as possible as the entire site will be redesigned in a short time. The above does not seem to work for me, though; it only returns a blank webpage (source below). I tested a basic php mail test, so I know it works.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>
for example, mail ('me@site.com', 'test', 'test message') sent the email with subject 'test' and body 'test message'.
So obviously, even as simple as I tried to keep it, I screwed up somewhere. Any help?