Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

questionnaire on web site

Status
Not open for further replies.

Hildegoat15

Technical User
Aug 3, 2001
38
CA
Hi,

I'm working for a respiratory services company and i'm developing their website. i'm wondering how easy it would be to set up an online questionnaire, asking questions to see if the visitor would be a candidate for home oxygen, etc. the results would be sent via email to us, and we can then do a follow-up if need be. i know how to create the forms and such, but i guess it's the actual processing that i'm asking about. i'm guessing i can't just put a simple mailto: in the action part of my form tag, so would i need to use some cgi scripting? and if so, how would i go about doing that? if anyone has any links that would help me, it'd be greatly appreciated.

-Matt
 
Hi,
yeah you need a server side script to process the form, you will find LOADS of free ones here

(remote hosting)

If you need more just shout...


É

endamcg-logo1b.gif

 
Hi Hilde,
I've just done a very similar thing, with help from the experts here. I have a registration form with various text, radio buttons, and check boxes, that on clicking of a button, performs a limited amount of validation and then sends the lot to a specified e-mail address, in a pleasant format, using a php script. I know very little about php or cgi come to that matter, but with the help from the people in these forums, managed to get it up and running. If you want my page and script as an example to get you up and running, let me know.
Marc
 
Marc,

i'd really appreciate seeing your solution as a starting point. i just graduated from a 2-year college programming course, so i've got some coding under my belt. i dont think it should be much of a problem for me -- i think i just need a bit of a kick-start. having learned c++, java, and perl (amongst many other languages), i'm assuming php would be somewhat similar to those. maybe it'd actually force me to learn some new stuff!

if you can post it up here, it'd be greatly appreciated. that way other people like me can maybe learn from it -- not just me.

and if anyone feels like checking out my company's site, i'm always open to suggestions and criticism. the url is
-Matt
 
Matt,
I wrote the HTML/JavaScript from scratch and am still learning, so I'm pretty sure there are better/different ways of doing it. The PHP I tailored knowing nothing about the langauge and had some problems getting the two to work, particularly with validating that at least one checkbox was entered, and then getting all entered values through to the e-mail. With help from this site I got it working evantually. HTML is:

<HTML>
<HEAD>
<TITLE>CRC Sculling Camps - Registration Page</TITLE>
<LINK REL=&quot;stylesheet&quot; HREF=&quot;crcstyles.css&quot; TYPE=&quot;text/css&quot;> <SCRIPT LANGUAGE=&quot;JavaScript&quot; TYPE=&quot;text/javascript&quot;>
<!-- Begin
function validform(regform)
{
if (regform.name.value == &quot;&quot;)
{ alert(&quot;Please enter your name&quot;)
regform.name.focus()
return false
}
if (regform.address.value == &quot;&quot;)
{ alert(&quot;Please enter your address&quot;)
regform.address.focus()
return false
}
if (regform.email.value == &quot;&quot;)
{ alert(&quot;Please enter your e-mail address&quot;)
regform.email.focus()
return false
}

if (regform.email.value.indexOf(&quot;@&quot;) == -1 || regform.email.value.lastIndexOf('.') == -1) {
alert(&quot;Please include a proper email address. ex: youremailhere@address.com&quot;);
regform.email.focus();
return false;
}


Campswitch = 0
for (i=0; i<regform[&quot;Camps[]&quot;].length;i++)
{ if (regform[&quot;Camps[]&quot;].checked)
{ Campswitch = 1
}
}
if (Campswitch == 0)
{ alert(&quot;Please select one or more Camps and dates that you are interested in&quot;)
return false
}
return true
}

// End -->
</SCRIPT>
</HEAD>
<BODY>
<!-- The line below is the line that have to be added to ALL pages that goes in the main frame -->
<SCRIPT LANGUAGE=&quot;JavaScript1.2&quot; SRC=&quot;cframe.js&quot; TYPE=&quot;text/javascript&quot;></SCRIPT>
<H1 ALIGN=&quot;center&quot;>Registration and Information request</H1>
<P ALIGN=&quot;center&quot;>Please fill out the following form and click the Submit
button to send. </P> <p align=&quot;center&quot;>We will then contact you with more information The fields
marked <FONT COLOR=&quot;#FF0000&quot;>*</FONT> are required.</P>
<FORM ONSUBMIT=&quot;return validform(this)&quot; METHOD=&quot;post&quot;
ACTION=&quot;formmail.php3&quot;>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;recipient&quot; VALUE=&quot;recipient@email.com&quot;>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;subject&quot; VALUE=&quot;Information Request&quot;>
<TABLE BORDER=&quot;0&quot; CELLPADDING=&quot;5&quot; WIDTH=&quot;90%&quot;>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;right&quot;> <B>Name:</B><FONT
COLOR=&quot;#FF0000&quot;>*</FONT> </TD>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot;>
<INPUT TYPE=&quot;text&quot; NAME=&quot;name&quot; SIZE=&quot;30&quot;> </TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;right&quot;> <B>Address:</B><FONT
COLOR=&quot;#FF0000&quot;>*</FONT> </TD>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot;> <TEXTAREA NAME=&quot;address&quot; ROWS=&quot;6&quot; COLS=&quot;45&quot;></TEXTAREA></TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;right&quot;> <B>Tel #:</B> </TD>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot;>
<INPUT TYPE=&quot;text&quot; NAME=&quot;phone&quot; SIZE=&quot;25&quot;> </TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;right&quot;> <B>E-Mail:</B><FONT
COLOR=&quot;#FF0000&quot;>*</FONT> </TD>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot;>
<INPUT TYPE=&quot;text&quot; NAME=&quot;email&quot; SIZE=&quot;50&quot;> </TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;Right&quot;> <B>Age:</B> </TD>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot;> <INPUT TYPE=&quot;text&quot; NAME=&quot;age&quot;
SIZE=&quot;3&quot;> </TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;Right&quot;> <B>Sex:</B></TD>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot;>
<INPUT TYPE=&quot;radio&quot; NAME=&quot;sex&quot; VALUE=&quot;Male&quot;>Male
<INPUT TYPE=&quot;radio&quot; NAME=&quot;sex&quot; VALUE=&quot;female&quot;>Female </TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;Right&quot;> <B>Experience Level:</B></TD>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot;>
<INPUT TYPE=&quot;radio&quot; NAME=&quot;Experience&quot; VALUE=&quot;Beginner&quot;>Beginner
<INPUT TYPE=&quot;radio&quot; NAME=&quot;Experience&quot; VALUE=&quot;Intermediate&quot;>Intermediate
<INPUT TYPE=&quot;radio&quot; NAME=&quot;Experience&quot; VALUE=&quot;Advanced&quot;>Advanced </TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;Right&quot;> <B>T-Shirt Size:</B></TD>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot;>
<INPUT TYPE=&quot;radio&quot; NAME=&quot;TShirtSize&quot; VALUE=&quot;S&quot;>S
<INPUT TYPE=&quot;radio&quot; NAME=&quot;TShirtSize&quot; VALUE=&quot;M&quot;>M
<INPUT TYPE=&quot;radio&quot; NAME=&quot;TShirtSize&quot; VALUE=&quot;L&quot;>L
<INPUT TYPE=&quot;radio&quot; NAME=&quot;TShirtSize&quot; VALUE=&quot;XL&quot;>XL </TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;right&quot;> <B>Please tell us how you heard about
the camps, or make any othe comments</B> </TD>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot;> <TEXTAREA NAME=&quot;Comments&quot; ROWS=&quot;6&quot; COLS=&quot;45&quot;></TEXTAREA></TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot; COLSPAN=&quot;2&quot;> <B> Please indicate which
camp(s) you are requesting information for:</B><FONT
COLOR=&quot;#FF0000&quot;>*</FONT></TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot; COLSPAN=&quot;2&quot;>
<INPUT TYPE=&quot;checkbox&quot; NAME=&quot;Camps[]&quot; VALUE=&quot;Henley&quot;> <B> Henley-on-Thames,
England: Sunday September 29 - Saturday October 5, 2002</B></TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot; COLSPAN=&quot;2&quot;>
<INPUT TYPE=&quot;checkbox&quot; NAME=&quot;Camps[]&quot; VALUE=&quot;Seville Week1&quot;> <B> Seville,
Spain: </B> Week One, <B> Sunday November 24 - Saturday November 30,
2002</B></TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot; COLSPAN=&quot;2&quot;>
<INPUT TYPE=&quot;checkbox&quot; NAME=&quot;Camps[]&quot; VALUE=&quot;Seville Week2&quot;> <B> Seville,
Spain: </B> Week Two, <B> Sunday December 1 - Saturday December 7,
2002</B></TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot; COLSPAN=&quot;2&quot;>
<INPUT TYPE=&quot;checkbox&quot; NAME=&quot;Camps[]&quot; VALUE=&quot;Elberton Week1&quot;> <B> Elberton,
Georgia: </B> Week One, <B> Sunday February 23 - Saturday March 1,
2003</B></TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot; COLSPAN=&quot;2&quot;>
<INPUT TYPE=&quot;checkbox&quot; NAME=&quot;Camps[]&quot; VALUE=&quot;Elberton Week2&quot;> <B> Elberton,
Georgia: </B> Week Two, <B> Sunday March 2 - Saturday March 8, 2003</B></TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot; COLSPAN=&quot;2&quot;>
<INPUT TYPE=&quot;checkbox&quot; NAME=&quot;Camps[]&quot; VALUE=&quot;Whistler&quot;> <B> Whistler BC,
Canada: April 2003</B></TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;left&quot; COLSPAN=&quot;2&quot;>
<INPUT TYPE=&quot;checkbox&quot; NAME=&quot;Camps[]&quot; VALUE=&quot;Penrith&quot;> <B> Penrith, Australia:
October 2003</B></TD>
</TR>
<TR VALIGN=&quot;TOP&quot;>
<TD VALIGN=&quot;TOP&quot; ALIGN=&quot;center&quot; COLSPAN=&quot;2&quot;>
<BUTTON TYPE=&quot;submit&quot; NAME=&quot;&quot;>
<IMG SRC=&quot;images/crcoar.gif&quot; WIDTH=&quot;70&quot; HEIGHT=&quot;22&quot; BORDER=&quot;0&quot;
ALT=&quot;Register&quot;><B> Click here to Submit </B></BUTTON>
<!-- <INPUT TYPE=&quot;IMAGE&quot; NAME=&quot;Image1&quot; VALUE=&quot;submit&quot; SRC=&quot;images/crcoar.gif&quot;> submit-->
</TD>
</TR>
</TABLE> </FORM> </BODY>
</HTML>

PHP is:

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY> <?PHP $fmt_Response=implode(&quot;&quot;, file(&quot;response.htt&quot;));
$fmt_Mail=implode(&quot;&quot;, file(&quot;Mail.htt&quot;));

while(list($Key, $Val)= each($HTTP_POST_VARS)) {
$fmt_Response=str_replace(&quot;{$Key}&quot;, $Val, $fmt_Response);
$fmt_Mail=str_replace(&quot;{$Key}&quot;, $Val, $fmt_Mail);
}

$name = $HTTP_POST_VARS[&quot;name&quot;];
$address = $HTTP_POST_VARS[&quot;address&quot;];
$phone = $HTTP_POST_VARS[&quot;phone&quot;];
$email = $HTTP_POST_VARS[&quot;email&quot;];
$age = $HTTP_POST_VARS[&quot;age&quot;];
$sex = $HTTP_POST_VARS[&quot;sex&quot;];
$Experience = $HTTP_POST_VARS[&quot;Experience&quot;];
$TShirtSize = $HTTP_POST_VARS[&quot;TShirtSize&quot;];
$Comments = $HTTP_POST_VARS[&quot;Comments&quot;];
$Camps = implode(&quot;,&quot;, $HTTP_POST_VARS[&quot;Camps&quot;]);

$mailText = &quot;$fmt_Mail \n\t Name: $name \n\t Address: $address \n\t Phone Number: $phone \n\t E-Mail: $email \n\t Sex: $sex \n\t Experience: $Experience \n\t T-ShirtSize: $TShirtSize \n\t Comments: $Comments \n\t Interested in Camps: $Camps &quot;;

mail($HTTP_POST_VARS[&quot;recipient&quot;], $HTTP_POST_VARS[&quot;subject&quot;], $mailText );
echo $fmt_Response;
?>
</BODY>
</HTML>

Let me know how you get on.
Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top