Link to home
Create AccountLog in
Avatar of Richard Winnick
Richard Winnick

asked on

lost variables javascript form post to php

Hi -
Having a problem when I post form output as name value pairs using javascript to server - Only the first variable 's (comment) value shows up in the php page on server - as follows -

I did not write this code - it is part of an sdk -

javascript to post form info

<script language-"javascript">
......relevant code .....
      // Add fields from HTML email form to Applet so they get uploaded
      // along with the selected file.
      
             var temp = document.uploadForm.commentText.value;
            document.appletName.addNameValuePair( "comment", temp );

             temp = document.uploadForm.userName.value;
            document.appletName.addNameValuePair( "username", temp );

             temp = document.uploadForm.myText.value;
            document.appletName.addNameValuePair( "mine", item );

........... </script>

php page on server

<?php
... relevant code ....
// Get posted variables. Assume register _globals is off.
$comments = strip_tags($_POST['comment']);
$uid = strip_tags($_POST['username']);
$mystuff = strip_tags($_POST['mine']);

echo "comments = $comments\n";
echo "comments = $uid\n";
echo "comments = $mystuff\n";

......?>

This works but only the value for the first variable 'comments' gets echoed -
I've tried eveything i can think of and can't figure out why this is happening -
what am i missing -

thanks -
Richard



SOLUTION
Avatar of aconrad
aconrad

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account