PDA

View Full Version : مشکل در نحوه ارسال اطلاعات از طریق ajax



p30_code
جمعه 11 بهمن 1392, 01:01 صبح
با سلام خدمت دوستان من یک صفحه بنام login.php که دستورات ajaxجهت پست شدن به صفحه allcomandes.php ارسال می شود که پس از دریافت اطلاعات نتیجه ای در بر ندارد فقط یک سری تگ های html نشون می دهد از شما دوستان تقاضایی راهنمایی را خواستارم با تشکر .
pages login.php


<html lang="en">
<head>
<meta charset="utf-8">

<style>
div {
display: none;
width: 500px;
height:500px;
background: #FFF;
border: 1px solid gray;
}
</style>


<script src="Slider/jquery-1.9.1.js" type="text/javascript"></script>
<script src="Slider/jquery-ui-1.10.2.custom.js"type="text/javascript"></script>


<script language="javascript" type="text/javascript">
function _$(id) {
return document.getElementById(id);
}

function send_ajax() {

var user=_$('txtuser').value;
var pass=_$('txtpass').value;


$.ajax({
url: "AllComands.php?cmd=cheklogin&user=" + user + "&pass=" + pass,
async: true,
success: function (data) {
alert(data);

},
error: function (data) {


}
});


}
</script>


</head>
<body dir="rtl">
<center>
<button>show the div</button>
<div>
<table border="1px" cellpadding="5px" style="background-color:gray">
<tr>
<td> Name:</td><td><input type="text" id="txtuser" onBlur="LeaveBox(this,'User Name ');" onFocus="EnterBox(this);" Text="User Name"/></td>
</tr>
<tr>
<td>PassWord:</td><td> <input type="text" id="txtpass" onFocus="EnterBox(this);"
onblur="LeaveBox(this,'Pass word');"Text="Password" /><br></td>
</tr>
<tr>
<td></td><td>
<input type="button" name="btnok" onClick="send_ajax();"value="Login"/></td>
</tr>
</table>

<br>

<script>
$( "button" ).click(function() {
$( "div" ).show( "drop", 500 );
});
</script>
</div>
</center>
</body>
</html>

pages allcomandes.php
[CODE]<?php

$s=$_GET["id"];
switch($s)
{
case "cheklogin":echo cheklogin();
break;

}
function cheklogin()
{
if($_POST["user"]== "admin" && $_POST["pass"]=="123")

return "true";
else
return "false";
}

?>

abolfazl-z
یک شنبه 13 بهمن 1392, 12:53 عصر
الان به نظر خودتون ربطی به امنیت دارد ؟ :متفکر:
تاپیک رو منتقل کنید یک جای دیگر بهتر نتیجه میگیرید. :لبخندساده: