Jump to content
php.lv forumi

mod_rewrite bojā jQuery


eT`

Recommended Posts

Tātad mans mod_rewrite bojā manu jQuery login formu

mani pārmet uz lapu, kas izpildās no gadījumā.

ar alert pārbaudīju, kādi ir dati, ko atgriež.

data satur veselas lapas DOM.

 

index.php

<script language="javascript">
$(document).ready(function()
{
$("#login_form").submit(function()
{
	$.post("../pages/login.php",{ user:$('#user').val(),pass:$('#pass').val(),rand:Math.random() } ,function(data)
       {
		if(data=='yes')
	  	{
			document.location='video';
	  	}
	  	else 
	  	{
			alert(data);
	  		document.location='pokers';
         	}	
       });
		return false;
});
$("#pass").blur(function()
{
	$("#login_form").trigger('submit');
});
});
</script>
<?php
$p=explode('/',$_SERVER['REQUEST_URI']);
if ($p[1]=='' || $p[1] == 'home') $p[1]='index';
if (file_exists($m = 'pages/'.$p[1].'.php')) {
include('pages/'.$p[1].'.php');
} else {
echo '<h2>Lapa nav atrasta!</h2>';
}
?>
<form method="post" id="login_form">

</form>

 

un login.php

<?php
if(isset($_POST["user"]) && $_POST["user"] != '' && isset($_POST["pass"]) && $_POST["pass"] != '')
{
$user = escape($_POST["user"]);
$pass = escape($_POST["pass"]);
$pass = md5(sha1($pass));
$q = query("SELECT * FROM users WHERE username='".$user."' AND pass='".$pass."'");
if(mysql_num_rows($q) > 0)
{
	echo 'yes';
	$_SESSION["logged"] = $user;

}
else
{
	echo 'no';
}
}
?>

 

un mans .htaccess

 

Options +FollowSymlinks 

RewriteEngine On 
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !^(.+)\.(css|js|jpg|gif|png|ico|pdf)$
RewriteRule ^(.*) index.php [QSA,L]

Link to comment
Share on other sites

it kā logina formu sataisīju šādi:

 

<script language="javascript">
$(document).ready(function()
{
$("#login_form").submit(function()
{
	$.post("login",{ user:$('#user').val(),pass:$('#pass').val(),rand:Math.random() } ,function(data)
       {
		document.location='home';
       });
		return false;
});
});
</script>

 

bet vai tā ir forši darīt?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...