i have a folder who has all of my code, css html js and php, all in their respective folders (index is not on any folder, php is on folder called php, css is on folder called css, js is on folder called js). So i am trying to create a log in menu where i can create new accounts and connect to a sql db. The problem is it tells me that it cannot find the folder containing this code (login.php) from an ajax call in jquery. My code is the following for further understanding:
$(document).ready(function(){
$("#submitUserForm").click(function(){
var nombre = $("#user").val();
var password = $("#pass").val();
var dataString = 'name1=' + nombre+ '&password=' +password;
if(nombre=="" | password == ""){
alert("Ha dejado campos vacíos");
}else{
$.ajax({
type: "POST",
url: "../php/login.php",
data: dataString,
cache: false,
});
}
return false;
});
});
I have also tried changing the file to the folder where the js is but i cant get it to work, and calling it with url: "login.php". This is my log in code:
<?php
$connection = mysql_connect("localhost", "myUser", "myPass");
$db = mysql_select_db("mydba", $connection);
$name1 = $_POST["user"];
$pass1 = $_POST["pass"];
$query = mysql_query("insert into form_element(userName, userPassword) values($name, $pass)");
//header("Location:../inicio.html");
mysql_close($connection);
?>
Can u help me make this ajax call work? thank you very much!