Reply to HELP! No params passed from jscript to PHP script

Your name:

Reply:


Posted by Sean.Dewis on 01/27/06 11:29

Hi

I've got a simple web form, with j script validation.

All i want it to do, once the form fields pass validation, is POST the
data to my PHP script for processing.

In a very simple html form without any j script validation, it works
fine.

Now I've messed with it, the PHP script doesn't get any data in it's
$_REQUEST variables.

Can someone please help me?

-----test.shtml-----

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script type="text/javascript" language="JavaScript">
<!-- Begin

function Reset() {
var ip = '<!--#echo var="REMOTE_ADDR"-->';
document.forms[0].elements[0].value = "";
document.forms[0].elements[1].value = "y...@emailaddress.com";
document.forms[0].elements[2].value = "07XXX123456";
document.forms[0].elements[3].value = "Please call me ASAP. Many
thanks.";
document.forms[0].elements[6].value = ip;
document.forms[0].elements[0].focus();
}

function submitForms() {
if ( (isName() ) && (isEmail()) && (isPhone()) && (isComment()) &&
(isFavorite()) )
if (confirm("\nYou're about to send your contact this message.\n\nClick
on YES to send.\n\nClick on NO to abort."))
{
alert("\nYour message will now be sent.\n\n\nThank you!");
return true;
}

else
{
alert("\nYou have chosen not to send the message.");
return false;
}

else
return false;
}

function isName() {
var str = document.forms[0].elements[0].value;
if (str == "") {
alert("\nThe NAME field is blank.\n\nPlease enter your name.")
document.forms[0].elements[0].focus();
return false;
}

for (var i = 0; i < str.length; i++)
{
var ch = str.substring(i, i + 1);
if (((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && ch != ' ')
{
alert("\nThe NAME field only accepts letters & spaces.\n\nPlease
re-enter your name.");
document.forms[0].elements[0].select();
document.forms[0].elements[0].focus();
return false;
}
}
return true;
}

function isEmail()
{
emailAddress=document.forms[0].elements[1].value;
if (document.forms[0].elements[1].value == "") {
alert("\nThe E-MAIL field is blank.\n\nPlease enter your e-mail
address.")
document.forms[0].elements[1].focus();
return false;
}

if (document.forms[0].elements[1].value.indexOf ('@',0) == -1 ||
document.forms[0].elements[1].value.indexOf ('.',0) == -1)
{
alert("\nThe E-MAIL field requires a \"@\" and a \".\"be
used.\n\nPlease re-enter your e-mail address.")
document.forms[0].elements[1].select();
document.forms[0].elements[1].focus();
return false;
}

else
{
toName();
return true;

}
}

function isPhone() {
var str = document.forms[0].elements[2].value;
if (str == "") {
alert("\nThe telephone number field is blank.\n\nPlease enter your
number.")
document.forms[0].elements[2].focus();
return false;
}

for (var i = 0; i < str.length; i++) {
var ch = str.substring(i, i + 1);
if ((ch < "0" || "9" < ch) && (ch < "+" || "+" < ch))
{
alert("\nThe telephone field only accepts numbers and the '+'
sign.\n\nPlease re-enter your number.");
document.forms[0].elements[2].select();
document.forms[0].elements[2].focus();
return false;
}
}
return true;
}

function isComment() {
if (document.forms[0].elements[4].value == "") {
if (confirm("\nYou're about to submit without leaving a
comment.\n\nClick on CANCEL to include a comment.\n\nClick on OK to
continue without a comment."))
return true
else
{
document.forms[0].elements[4].focus();
return false;
}
}

else
return true
}

function isFavorite() {

return true
}

// End -->
</script>

<title></title>
</head>

<body onload="Reset()" vlink="#ffff99" alink="#0000ff" link="#ffcc00"
bgcolor="#e1e1e1">
<br>
<br>

<center><font color="#800000">
<h1><font color="#800000">Send a message</font></h1> </font>
</center>

<center>

<form enctype="text/plain" name="details" method="POST"
action="testsend.php" onsubmit="document.details.submit()">
<table border="0" width="400">
<tr>
<td align="middle"><font color="#800000"><strong>
Enter your name:</strong></font></td>

<td align="middle"><font color="#800000"><strong>
Your e-mail
address:<br><font size="1">(this will be used to provide you with
a
copy of the message)</font>
</strong></font></td>
</tr>

<tr>
<td align="middle"><input name="custName" size="30"
maxlength="30"></td>

<td align="middle"><input name="email" size="30"
maxlength="40" value="y...@emailaddress.com"></td>
</tr>

<tr>
<td align="middle"><font color="#800000"><strong>Your
phone number:</strong></font></td>

<td align="middle"><font color="#800000"><strong>
<input maxlength="15" size="15" value="07XXX123456"
name="custTel"></strong></font></td>
</tr>

<tr>
<td align="middle">
</td>

<td align="middle"> </td>
</tr>
</table>

<center>
<font color="#800000"><strong>Your comments or
additional details for your contact:</strong></font>
<br><textarea name="callback" wrap="yes" cols="50">Please
call me ASAP. Many thanks.
</textarea>
</center>

<center>

</center>

<center>
<input type="submit" value="Send" style="WIDTH: 90px;
HEIGHT: 39px" size="28" name="submit">
<input style="WIDTH: 73px; HEIGHT:
41px" onclick="Reset()" type="reset" size="27" value="Clear
Form" name="reset">
<br>
<br>
<font size="-1"><font size="1">Your IP address (logged
for security purposes)</font>
<br>
</font>
</center>

<center>
<input maxlength="15" size="12" name="remIP" readonly=""
style="WIDTH: 104px; HEIGHT: 22px">
</center>
</form>

<br>
<br>
<br>
<br>
</center>
</body>
</html>

--------------testsend.php-------------

<?php

$reqID = '2'; // $_REQUEST['cID'] ; This is meant to be set at 2 for
testing
$callback = $_REQUEST['callback'] ;
$custName = $_REQUEST['custName'] ;
$custTel = $_REQUEST['custTel'] ;
$serverIP = $_SERVER['REMOTE_ADDR'] ;

printf("cID from FORM POST = $reqID<br><br><br>");
printf("Your IP address: $serverIP<BR>") ;
printf("callback(comments)=$callback<BR>");
printf("custName=$custName<BR>");
printf("custTel=$custTel<BR>");

?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация