troubleshooting Question

How to transfer vbscript variable to php variable on the same page?

Avatar of TrevorParnhamntl
TrevorParnhamntl asked on
PHP
11 Comments1 Solution766 ViewsLast Modified:
I have a .php file where I retrieve data from a mysql database, I then use html on the same page to offer options based on the query result.
This is done using a form which is posted back to the same page using php_self.
I then run some calculations using a combination of html and php and then offer the user further options again using a form and php_self. the option the user chooses is posted to a text box (Text1).
I then want to use that information to send back to my database.
The problem I have is that I don't seem to be able to retrieve the information in the text box. I can retrieve it using vbscript. I get an undefined index error. Testing with Isset shows that the variable hasn't been assigned in php
My question is how can I retrieve it using php, either directly from the user choice or from the vbscript variable?
I have included my code
<?php
ini_set('display_errors','1');
error_reporting(E_ALL);
?>

<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript"> 
<!--
Sub Submit_OnClick
  Dim TheForm
  Dim Choice
  Set TheForm = Document.ValidForm
    Choice=TheForm.Text1.Value
 if Choice<>"" then
'MsgBox "You Chose  " & Choice
end if
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="ValidForm">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<INPUT NAME="Text1" TYPE="TEXT" SIZE="20">
Select Service Required:
<INPUT TYPE="radio" NAME="Prices" VALUE="1"
   onClick="Text1.value = 'Fully Trackable Courier'"> Fully Trackable Courier
<INPUT TYPE="radio" NAME="Prices" VALUE="2"
   onClick="Text1.value = 'Postal Airmail Service'"> Postal Airmail Service
<INPUT TYPE="radio" NAME="Prices" VALUE="3"
   onClick="Text1.value = 'International Signed for'"> International Signed for
<INPUT NAME="Submit" TYPE="BUTTON" VALUE="Assign">
</FORM>
<?php
if(isset($_POST['Text1'])){
$var =$_POST['Text1'];
echo $var;
   }
?>
</BODY>
<HTML>

Open in new window

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros