Save in BD from a form

Hi I hope someone can help me, my problem is this I’m basabdome in code examples to send and save but in response sends me the code in the file queesta coneccion.php and stores nothing in the database that I can do?

[code]
var myForm, formData;
function doOnLoad() {
formData = [
{ type:“input” , name:“nombre”, label:“Nombre” },
{ type:“input” , name:“apellidoP”, label:“Apellido Paterno” },
{ type:“input” , name:“apellidoM”, label:“Apellido Materno” },
{ type:“select” , name:“edad”, label:“Edad”, inputWidth:140, options:[
{ value:“edad”, text:“De 18 a 29” },
{ value:“edad”, text:“De 30 a 59” },
{ value:“edad”, text:“De 60 en adelante” }
] },
{ type:“button” , name:“aceptar”, value:“Aceptar” },
{ type:“button” , name:“cancelar”, value:“Cancelar” }
];
myForm = new dhtmlXForm(“myForm”, formData);

		myForm.attachEvent("onButtonClick", function(id){
			if (id == "cancelar")
				{
		if(confirm("Esta seguro que quiere cancelara la operación?"))
		{
		    window.opener = window.self;
            window.close();
	   }
	   else
	   {
	        
		windows.location.href="preferncias.htm"
		
	    }
	}
	
			
			if (id == "aceptar")
				myForm.send('conecxion.php', function(loader, response){
					alert(response);
				});
		});
			
		
	}
	
</script>
[/code]

Hi there!

I got EXACTLY the same issue:

I’m working in a logIn system which works perfect with a standard html form with:

<form action="src/auth/login.php" method="post" >

I figured out that this code:

myForm.attachEvent("onButtonClick",function(id){ if(id=="login"){ this.send("src/auth/login.php", "post", function(loader, response){ alert(response); }); } })

…sends the Form Data to the sendURL - and you get the Response - means: If in that File is any echo or print command, you get that back in your alert(response). But dhtmlx doesn’t’ go to that page.

In my login file I check username and password and if that’s OK I simply do this:

header('Location: http://'.$hostname.'/start.php');

But this seems not to work with dhtmlx…

header-location doesn’t have effect on ajax calls. You can change it on server side as

echo 'http://'.$hostname.'/start.php';

And on client side use

myForm.send('conecxion.php', function(loader, response){ if (response) document.location.href = response; });