...

View Full Version : "POST" and "GET in the same page



jazzed1026
08-05-2003, 03:00 AM
I am trying to use "POST" and "GET in the same page. Script 1 is to be filled by the visitor and sent to my servers email address. Script 2 is used to check for foul language. Each script works independently of the other. How do I combined the two and keep the form names, validations etc. etc. in Script 1?

I need the script to check the validation and run the language filter before being sent.

I used MS Front Page to create Script 1. Script 2 came from JS-Examples.com

Any help will be greatly appreciated!

SCRIPT 1:

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Copyright 2002 - Carole Nickerson - TheNetter.com - http://web.thenetter.com">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<title>Submit Public Concerns</title>
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
&nbsp;
<center>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=1 WIDTH="664" BACKGROUND="images/bg2.jpg" >
<tr VALIGN=TOP>
<td VALIGN=TOP><img SRC="images/Public%20Concerns%20Title.jpg" width="664" height="75">
<center>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=2 WIDTH="664" BACKGROUND="images/whiteblock2.gif" >
<tr VALIGN=TOP>
<td VALIGN=TOP WIDTH="134"><img SRC="images/button.jpg" width="134" height="24"><img SRC="images/button.jpg" width="134" height="24"><img SRC="images/button.jpg" width="134" height="24"><img SRC="images/button.jpg" width="134" height="24"><img SRC="images/button.jpg" width="134" height="24"><img SRC="images/button.jpg" width="134" height="24"><img SRC="images/button.jpg" width="134" height="24"></td>

<td WIDTH="530">
<center><table BORDER=0 CELLSPACING=6 CELLPADDING=6 COLS=1 WIDTH="100%" >
<tr VALIGN=TOP>
<td VALIGN=TOP></td>
</tr>
</table></center>
<!--webbot BOT="GeneratedScript" PREVIEW=" " startspan --><script Language="JavaScript" Type="text/javascript"><!--
function FrontPage_Form1_Validator(theForm)
{

if (theForm.Concerns.value == "")
{
alert("Please enter a value for the \"Concerns\" field.");
theForm.Concerns.focus();
return (false);
}

if (theForm.Concerns.value.length < 10)
{
alert("Please enter at least 10 characters in the \"Concerns\" field.");
theForm.Concerns.focus();
return (false);
}

if (theForm.Concerns.value.length > 250)
{
alert("Please enter at most 250 characters in the \"Concerns\" field.");
theForm.Concerns.focus();
return (false);
}

var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 0123456789-!@#$%^&*()_+:;\"'\\/?><.,= \t\r\n\f";
var checkStr = theForm.Concerns.value;
var allValid = true;
var validGroups = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please enter only letter, digit, whitespace and \"!@#$%^&*()_+:;\"'\\/?><.,=\" characters in the \"Concerns\" field.");
theForm.Concerns.focus();
return (false);
}
return (true);
}
//--></script><!--webbot BOT="GeneratedScript" endspan --><form method="POST" action="_derived/nortbots.htm" onsubmit="location.href='_derived/nortbots.htm';return false;" language="JavaScript" name="FrontPage_Form1" webbot-onSubmit="return FrontPage_Form1_Validator(this)" webbot-action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="Text Files/SubmitPublic.txt" S-Format="TEXT/PRE" S-Label-Fields="TRUE" B-Reverse-Chronology="FALSE" S-Email-Format="TEXT/PRE" S-Email-Address="webmaster@erc.dyndns.info" B-Email-Label-Fields="TRUE" B-Email-Subject-From-Field="FALSE" S-Email-Subject="Public Concerns" S-Date-Format="%A %B %d, %Y" S-Time-Format="%I:%M:%S %p %Z" S-Builtin-Fields="Date Time" S-Form-Fields="Concerns " U-Confirmation-Url="submitthankyou.html" startspan --><strong>[FrontPage Save Results Component]</strong><!--webbot bot="SaveResults" i-checksum="6561" endspan --><p>
&nbsp;
<!--webbot bot="Validation" s-display-name="Concerns" s-data-type="String" b-allow-letters="TRUE" b-allow-digits="TRUE" b-allow-whitespace="TRUE" s-allow-other-chars="!@#$%^&amp;*()_+:;&quot;'\/?&gt;&lt;.,=" b-value-required="TRUE" i-minimum-length="10" i-maximum-length="250" --><textarea rows="15" name="Concerns" cols="58" tabindex="1"></textarea></p>
<p align="center">
<input type="submit" value="Submit" name="Submit" tabindex="2">
<input type="reset" value="Reset" name="Reset" tabindex="3"></p>
</form>
</td>
</tr>
</table></center>
<img SRC="images/bottom.jpg" width="664" height="40"></td>
</tr>
</table></center>

<center>
<p></p>
</center>

</body>
</html>

SCRIPT 2

<!-- saved from url=(0022)http://internet.e-mail -->
<html>
<head>
<!--
This file retrieved from the JS-Examples archives
http://www.js-examples.com
1000s of free ready to use scripts, tutorials, forums.
Author: Premshree Pillai - http://www.qiksearch.com
-->

<style type="text/css">
..ip{border:#000000 solid 1px; width:80%}
..btn{border:#000000 solid 1px; background:#EFEFEF; font-weight:bold; cursor:hand}
..link{font-family:verdana,arial,helvetica; font-size:8pt; color:#FFFFFF}
..link:hover{font-family:verdana,arial,helvetica; font-size:8pt; color:#CCCCFF}
</style>
<!--BEGIN WORD FILTER JAVASCRIPT-->
<script language="JavaScript">
// Word Filter 2.0
// (c) 2002 Premshree Pillai
// Created : 29 September 2002
// http://www.qiksearch.com
// http://javascript.qik.cjb.net

var swear_words_arr=new Array("hi","hello","cheers");
var swear_alert_arr=new Array();
var swear_alert_count=0;

function reset_alert_count()
{
swear_alert_count=0;
}

function wordFilter(form,fields)
{
reset_alert_count();
var compare_text;
var fieldErrArr=new Array();
var fieldErrIndex=0;
for(var i=0; i<fields.length; i++)
{
eval('compare_text=document.' + form + '.' + fields[i] + '.value;');
for(var j=0; j<swear_words_arr.length; j++)
{
for(var k=0; k<(compare_text.length); k++)
{
if(swear_words_arr[j]==compare_text.substring(k,(k+swear_words_arr[j].length)).toLowerCase())
{
swear_alert_arr[swear_alert_count]=compare_text.substring(k,(k+swear_words_arr[j].length));
swear_alert_count++;
fieldErrArr[fieldErrIndex]=i;
fieldErrIndex++;
}
}
}
}
var alert_text="";
for(var k=1; k<=swear_alert_count; k++)
{
alert_text+="\n" + "(" + k + ") " + swear_alert_arr[k-1];
eval('compare_text=document.' + form + '.' + fields[fieldErrArr[0]] + '.focus();');
eval('compare_text=document.' + form + '.' + fields[fieldErrArr[0]] + '.select();');
}
if(swear_alert_count>0)
{
alert("The form cannot be submitted.\nThe following illegal words were found:\n_______________________________\n" + alert_text + "\n_______________________________");
return false;
}
else
{
return true;
}
}
</script>


</head>
<body>

<table cellspacing="0" cellpadding="0" bgcolor="#0066CC" align="center" width="446"><tr><td></td></tr></table>
<table cellspacing="0" cellpadding="0" bgcolor="#0066CC" align="center" width="448"><tr><td></td></tr></table>
<table style="border:#0066CC solid 2px; width:450px" align="center" cellspacing="0" cellpadding="0"><tr><td>
<table style="width:100%; background:#0066CC"><tr><td align="middle"><span style="font-family:courier new,courier,verdana,arial; font-weight:bold; font-size:30pt; color:#FFFFFF; filter:Shadow(direction=45, color=#000000); width:100%">Word Filter 2.0</span></td></tr></table>
<!--BEGIN FORM-->
<table><tr><td>
<form name="form1" method="get" action="" onSubmit="return wordFilter('form1',['name','email','subject','message']);">
<table>
<tr><td>Name :</td><td><input type="text" name="name" class="ip" value="hi"></td></tr>
<tr><td>E-mail :</td><td><input type="text" name="email" class="ip" value="hello"></td></tr>
<tr><td>Subject :</td><td><input type="text" name="subject" class="ip"></td></tr>
<tr><td>Message</td><td><textarea name="message" rows="5" cols="30">cheers</textarea></td></tr>
</table>
<input type="submit" value="Submit Form" class="btn">
</form>
</td></tr></table>
<!--END FORM-->

<table><tr><td>
This JavaScript is a "Word Filter". It is a type of form validator.
When the user submits some text, the validator will check the text for words that has to be filtered.
<br><br>The words that have to be filtered must be added to the array swear_words_arr. When the user
types the text and hits the submit button, if the text contains any word that is present in the array
swear_words_arr, the form will not be submitted.
<br><br>Place the &lt;script&gt; in the &lt;HEAD&gt; section of your page.
<br><br><b>In this version, you can validate multiple form fields. View the source and see the section
marked </b>&lt;--BEGIN FORM--&gt;
<br><br>The script can be used for validation of swear words etc.
</td></tr></table>
<BR>
<BR>
This example does not have swear words in it, but uses the following as the filtered words:
<list><li>"hi"<li>"hello"<li>"cheers"</list>

<BR><center><a href='http://www.js-examples.com'>JS-Examples.com</a></center>
</body>
</html>

P.S. I do not need the "Name" "E-Mail" & "Subject" from Script 2 and would like to only have one Submit button.

Thanx,
Jazzed1026

Jason
08-05-2003, 09:25 PM
Im not entirely positive on this but I know you only need 1 of GET or POST and either of them will be how you access variables on the next page. You shouldn't need either of them to access a script on the current page to do the word filter for swear words or whatnot. You might concider having a single form and put it all in a POST. You could possibly have it redirect to a 'middle' page that would access the filter for swear words and redirect to the appropriate page if they are found or not.


Jason

jazzed1026
08-05-2003, 10:34 PM
Jason,

Thank you for your reply however, being a newbie I am not quite sure how to do this. Could you tutor??


Jazzed1026

Jason
08-05-2003, 11:38 PM
jazzed1026

ha, simple problem when I stare at code long enough...you just need to delete that form that was created in script 2 basically. You then can copy the <form > tag to your script 1 and replace the key parts that are the same in both...then in the return wordFilter('form1',['name','email','subject','mess
age
you can replace "name" and "email"....with the names of the fields you created...

hope that helps...


Jason



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum