How to transfer variables to PHP ?

Good morning,
I am looking for the way to transfer data from a form to a php script.
Unfortunately my does NOT work.
Please help me.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Test</title>
	
	<link rel="stylesheet" type="text/css" href="codebase/dhtmlx.css">
	<script src="codebase/dhtmlx.js" type="text/javascript"></script>
	
	<link rel="stylesheet" type="text/css" href="../dhtmlx/dhtmlxForm/codebase/skins/dhtmlxform_dhx_skyblue.css">
    <script src="../dhtmlx/dhtmlxForm/codebase/dhtmlxcommon.js"></script>
    <script src="../dhtmlx/dhtmlxForm/codebase/dhtmlxform.js"></script>
	
	<script>
	  var dhxForm;
	  var formData;
	  
	  var Username
	  var Password
	  
	  function doOnLoad()	{
		formData = [
		  {
		  type: "settings",
		  position: "label-left",
		  labelAlign: "right",
		  labelWidth: 80,
		  inputWidth: 120
		  },
		  {
		  type: "input",
		  name: "Username",
		  label: "Username",
		  value: "login",
		  validate: "NotEmpty"
		  },
		  {
		  type: "password",
		  name: "Password",
		  label: "Password",
		  value: "123",
		  validate: "NotEmpty"
		  },
		  {
		  type: "button",
		  name: "cmdSend",
		  offsetLeft: 87,
		  width: 82,
		  value: "send",
		  command: "doFormSend"
		  },
		];
		
		dhxForm = new dhtmlXForm("dhxForm", formData);
		
		dhxForm.attachEvent("onButtonClick", function(name, command) {
			window[command]();
		});
		
	  } 
	  
	  function doFormSend() {
		alert("sending ...");
		dhxForm.send("php/mirror.php", "post");
	  }
	  
    </script>
	
</head>


<body onload="doOnLoad()">
	<div id="dhxForm"></div>
</body>
</html>

and here the code of /php/mirror.php


<?php

	if(isset($_REQUEST["Username"])) {
		print_r($_REQUEST["Username"]);
	}else{
		echo "variable NOT set ...";
	}
	
	if(isset($_REQUEST["Password"])) {
		print_r($_REQUEST["Password"]);
	}else{
		echo "variable NOT set ...";
	}

?>

Thank you very much in advance.
Best regards
Juergen Heyn, Wilhelmshaven, Germany

Hello

Strange…
Could you please prvide completed demo including all needed js/css/php files?

Hi Andrei,

see attached zip file for all files required to run the html file.
The folders path has to be corrected.

Hope you can find a solution for me.
In my previous post the problem could be the on ValidateSuccess event ???

Best regards
Juergen Heyn, Wilhelmshaven, Germany
test001.zip (257 KB)

Demo works fine
post data: Username=login&Password=123
response from php: login123

Good evening,

unfortunately I still can NOT get the demo to run.
Not on my xampp webserver (localhost) and NOT on my webspace provider.
Attached I provide the phpinfo data from my localhost.

Any idea is very welcome.

Best regards
Juergen Heyn, Wilhelmshaven, Germany
PHP_Info.zip (67.5 KB)

could you please provide direct link?
add any file on server with code:

<?php print_r($_REQUEST); ?>

and provide its filename

Good afternoon,

sorry for the delay …
Here is the live link to the file:
heliheyn.de/FlOps/test001.html

The file where I expect the data to be sent to:
heliheyn.de/FlOps/php/mirror.php

I am using Windows 7 Pro Sp 1, Browser IE 9.
I assume that there are somewhere security settings ???

Hope for help.
Best regards
Juergen Heyn, Wilhelmshaven, Germany

test001.html also works correctly

Response is:
Array
(
[Username] => login
[Password] => 123
)

try this way:
dhxForm.send(“php/mirror.php”, “post”, function®{
alert(r.xmlDoc.responseText);
});

Hi Andrei,

thank you for your reply.
With your suggestion the alert message from the website is correct. (see image)

But if I call mirror.php the output is only: Array()
with no further information.

Do you have any other idea ?
Thank you very much in advance.
Best regards
Juergen Heyn, Wilhelmshaven, Germany

This is because you call mirror.php w/o params
Try this link:
heliheyn.de/FlOps/php/mirror … _2=value_2

Good afternoon Andrei,

could you please check the following live link:
heliheyn.de/FlOps/test003.html

[code] function doFormSend() {
Username = dhxForm.getItemValue(“Username”);
Password = dhxForm.getItemValue(“Password”);

		params = "Username="+Username+"&Password="+Password;
		document.writeln(params);
	
		dhtmlxAjax.post("php/mirror.php", params, callbackFunction);
		var loader = dhtmlxAjax.postSync("php/mirror.php", params);
		window.location.href = "php/mirror.php";
  }

[/code]

This works on my computer.
Is this the correct and intended way to hand over variables to a php file ???

Best regards
Juergen Heyn, Wilhelmshaven, Germany

Hi

What are you expecting from this demo?

Our form send data using ajax, in bg, it not reload page like regular form.

Dear Andrei,

it is very fustrating. I do NOT manage to transfer variables from a form to a php file.
May be it’s my fault, because I simply don’t konw how to call the next page with a button click.

heliheyn.de/FlOps/test001.html displays correct values in alert window.
But when I call after button click the heliheyn.de/FlOps/php/mirror.php the values are lost and it says: Array().

I read through all documentation, I tried almost very line of source code but I am not able to transfer any variable from a form to a php file.

I would appreciate if you could please provide a working sample code that demonstrates the technique of transferring variables to a php file. And how to call the this php file the variables were sent to.

Regards
Juergen

Dear Andrei,

I need to get the following link to work:
heliheyn.de/FlOps/index.html

If I can’t manage to get the variables from the form transfered to mirror.php I have to terminate the evaluation of any dhtmlx components.

Regards
Juergen

Hello

I have a demo created for another guy (too similar problems).
It have comments inside, please check.
demo.zip (32.8 KB)

Dear Andrei,

thank you very much for the demo.
It works perfectly for me.

Best regards.
Juergen Heyn, Wilhelmshaven, Germany