我需要幫助,當我按下提交按鈕我想我的回聲顯示在我有我的跨度的頁面,而不是像(../ addIPSE.php)的新頁面...爲什麼我的網頁加載php文件?
我的index.html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="js/jQueryMobile/jquery.mobile-1.4.5.min.css" />
<script type="text/javascript" src="js/jquery-2.2.0.min.js"></script>
<script type="text/javascript" src="js/jQueryMobile/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript" src="js/addIPSE.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header" position="fixed">
<h1>Page Title</h1>
</div><!-- /header -->
<div data-role="content">
<form id="addIPSEform" action="addIPSE.php" method="post">
<label for="addIPSE">IPSE:</label>
<input type="text" name="addIPSE" id="addIPSE" placeholder="IPSE..." value="" data-clear-btn="true">
<button id="submitButton" class="ui-btn ui-corner-all">Submit</button>
</form>
<span name="result" id="result"></span>
</div><!-- /content -->
<div data-role="footer" position="fixed">
<h4>Page Footer</h4>
</div><!-- /footer -->
</div><!-- /page -->
</body>
</html>
我addIPSE.php
<?php
include_once('DBconnection.php');
$IPSE = $_POST['addIPSE'];
$lookForIPSEinDB = mysql_query("SELECT IPSE FROM myDB WHERE IPSE='$IPSE'");
if (mysql_num_rows($lookForIPSEinDB) != 0) {
mysql_query("UPDATE myDB SET antal_login = antal_login + 1 WHERE IPSE='".$IPSE."'");
echo "Already in DB, adding +1 antal_login...";
}
else {
mysql_query("INSERT into myDB(IPSE) VALUES('".$IPSE."')");
mysql_query("UPDATE myDB SET antal_login = antal_login + 1 WHERE IPSE='".$IPSE."'");
echo "New IPSE added in DB...";
}
?>
我addIPSE.js
$("#submitButton").click(function() {
var inputIPSE = $("#addIPSE").val();
$.post($("#addIPSEform").attr("action"), inputIPSE, function(info){ $("#result").html(info); });
});
$("#addIPSEform").submit(function() {
return false;
});
另外,當我按下提交按鈕時,我首先進入一個全白頁面,然後我必須刷新頁面才能看到我的回聲,但我得到的唯一回應是「已在數據庫..:」,而且它不顯示在我的索引頁上的跨度...
我只是要提交IPSE: 「或睡覺(10000000)或1 ='1' - 哦,親愛的,我已經崩潰了你的服務器。 –