<?php session_start(); include 'forms.php'; include 'config.php'; include 'lib.php'; ?>
<html>
<head>
<meta charset="UTF-8">
<title>Login</title>
<link href="css/main.css" rel="stylesheet" />
</head>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script>
<script type="text/javascript">
$(document).ready(function(){
$("#check").click(function(){
var username = ("<?= $username ?>");
$.ajax({
url:"ajax.php",
data :'username=' +username,
success: function(ajax){
$("#ajax").append(ajax);
}
});
})
});
</script>
</body>
</html>
<?php
if ($_SESSION['username'])
echo "welcome, ".$_SESSION['username']."!<br><a href='logout.php'>LOGOUT</a>";
else
die("You must be logged in");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$rpassword = $_GET["rpassword"];
$password =$_GET["password"];
$firstname =$_GET["firstname"];
$secondname =$_GET["secondname"];
$username =$_GET["username"];
if (isset ($_GET['username']))
{
if($password==$rpassword){ //checks if passwords match
$query = "INSERT INTO users VALUES (NULL,'$firstname','$secondname','$username','$password')";
mysql_query($query) or die("$query failed with error ".mysql_error());
}
else
echo"PASSWORD DONT MATCH";
}
loginform();
get();
?>
need to transfer php variable $username into javascript varible var username
for some reason the above "var username = ("<?= $username ?>");" line dont work
How ever if i replaced ("<?= $username ?>") with "username" it works please helk
thnks