Click to See Complete Forum and Search --> : Javascript form validation with php help


spyke01
02-23-2003, 03:20 PM
ok guys i get this error:
line:19
char: 1
error:Object doesnt support this property or method
Code:0
url:http://localhost/linux/contact.php?

heres the source for the pages:
:::mailval.js:::
<!--
function TheFormCheck() {
if (document.emailf.from.value=="" && document.emailf.name.value=="")
{
alert("Yeah...you kinda need to include your name and return email if you want me to write back.");
document.emailf.from.focus(); return false
}

if (document.emailf.from.value!="")
{
if (document.emailf.from.value.indexOf("@")==-1 || document.emailf.from.value.indexOf(".")==-1 || document.emailf.from.value.indexOf(" ")!=-1 || document.emailf.from.value.length<6)
{
alert("Sorry, your email address is invalid. Try using a real one");
document.emailf.from.focus(); return false
}
}

if (document.emailf.name.indexOf("://")!=-1 || document.emailf.name.indexOf(" ")!=-1)
{
alert("Please type in your name.");
document.emailf.name.focus(); return false
}

if (document.emailf.subject.indexOf("://")!=-1)
{
alert("The string :// is not allowed in the subject textbox.");
document.emailf.subject.focus(); return false
}


if (document.emailf.Message.indexOf(" ")!=-1 || document.emailf.Message.indexOf("%20")!=-1 || document.emailf.Message.indexOf("<")!=-1 || document.emailf.Message.indexOf(">")!=-1 || document.emailf.Message.indexOf("&gt")!=-1 || document.emailf.Message.indexOf("&lt")!=-1 || document.emailf.Message.indexOf("<script")!=-1 || document.emailf.Message.indexOf("img src")!=-1 || document.emailf.Message.indexOf("a href")!=-1 || document.emailf.Message.indexOf("<frame")!=-1)
{
alert("Your message contains dissalowed characters. Please do not use javascript or html of any sort, these languages will keep your email from being sent.");
document.emailf.Message.focus(); return false
}
}

//-->

:::contact.php:::
<?PHP
ob_start();
?>
<html>
<head>
<title>--==Email Me==--</title>
<script language="JavaScript" src="../javascripts/mailval.js">
</script>
</head>
<link rel="stylesheet" type="text/css" href="../stylesheets/rpg.css">
<body bgcolor=black text=white>

<?php
$phpbb_root_path = '../forum/';

//
//
//

#$phpbb_root_path = 'forum/';

define ('IN_PHPBB', true);

if (!file_exists($phpbb_root_path . 'extension.inc'))
{
die ('<tt><b>Watashi-noAnimeRPG:</b>
$phpbb_root_path is wrong and does not point to your forum.</tt>');
}

//
// phpBB related files
//

include_once ($phpbb_root_path . 'extension.inc');
include_once ($phpbb_root_path . 'common.' . $phpEx);
include_once ($phpbb_root_path . 'includes/bbcode.' . $phpEx);

//
// Fetch All related files - we do need all these because the portal is a
// huge example
//
include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);
include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/users.' . $phpEx);

//
// start session management
//

$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
init_userprefs($userdata);
phpbb_disconnect();

if ( $userdata['session_logged_in'] )
{
include_once ('pages/llinks.php');
?>

<form action="<? echo $lmenuvar[C_MAIL]; ?>" method="POST" onSubmit="return TheFormCheck()" name="emailf">
You can send me messages with the following form.<br>
<font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<strong>Email:</strong>
<br>
<input type="text" name="from">
<br>
<strong>Name:</strong>
<br>
<input type="text" name="name">
<br>
<strong>Subject:</strong>
<br>
<input type="text" name="subject">
<br>
<strong>Message:</strong>
<br>
<textarea name="Message" Rows=8 COLS=65></textarea>
<br>
<input name="submit" class="loginbutton" type="submit" value="Submit">
</form>
<? }
else if ( !$userdata['session_logged_in'] )
{ ?>
You do not have access rights to view/use this file. Please login to be able to view/use this file
<? }
ob_end_flush();
?>


:::mail.php:::
<?
function qp_encoding($Message) {

/* Build (most polpular) Extended ASCII Char/Hex MAP (characters >127 & <255) */
for ($i=0; $i<127; $i++) {
$CharList[$i] = "/".chr($i+128)."/";
$HexList[$i] = "=".strtoupper(bin2hex(chr($i+128)));
}

/* Encode equal sign & 8-bit characters as equal signs followed by their hexadecimal values */
$Message = str_replace("=", "=3D", $Message);
$Message = preg_replace($CharList, $HexList, $Message);

/* Lines longer than 76 characters (size limit for quoted-printable Content-Transfer-Encoding)
will be cut after character 75 and an equals sign is appended to these lines. */
$MessageLines = split("\n", $Message);
$Message_qp = "";
while(list(, $Line) = each($MessageLines)) {
if (strlen($Line) > 75) {
$Pointer = 0;
while ($Pointer <= strlen($Line)) {
$Offset = 0;
if (preg_match("/^=(3D|([8-9A-F]{1}[0-9A-F]{1}))$/", substr($Line, ($Pointer+73), 3))) $Offset=-2;
if (preg_match("/^=(3D|([8-9A-F]{1}[0-9A-F]{1}))$/", substr($Line, ($Pointer+74), 3))) $Offset=-1;
$Message_qp.= substr($Line, $Pointer, (75+$Offset))."=\n";
if ((strlen($Line) - ($Pointer+75)) <= 75) {
$Message_qp.= substr($Line, ($Pointer+75+$Offset))."\n";
break 1;
}
$Pointer+= 75+$Offset;
}
} else {
$Message_qp.= $Line."\n";
}
}
return $Message_qp;
}
mail("padenc2001@yahoo.com", $subject, $Message_qp, $from)
?>
<html>
<head><title>--==Email Me==--</title></head>
<link rel="stylesheet" type="text/css" href="../stylesheets/rpg.css">
<body bgcolor=black>
<font class=smoke>Thanks for your email, i will respond as soon as i can.</font><br>
</html>



any help would be greatly appreciated, thanx guys
Spyke01

spyke01
02-24-2003, 07:32 AM
didnt work, im test running on IE6 on apache 1.3.27 on win98se

spyke01
02-26-2003, 04:11 PM
ok, had to change codee, and upload to angelfire for now, long story:

http://wnarpg.no-ip.com/ac53.htm

type in an email, and then in the name and subject put :// and in messgae, put: <? <java &lt
press send, and an error icon will pop up where it should usually Done. thanx alot, hope the code still works the same, had to take out most of the php

spyke01
03-01-2003, 09:50 AM
yeah, it was still using the php variable stuff, but its supposed to give a javascript error when it sends

spyke01
03-02-2003, 08:13 AM
no, maybe its stopped griping, but it was griping, i was tryin to keep it from griping, its supposed to check for code in the message, and then not send it and tell them they cant do that, or cant use web addresses for a name