- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用phonegap 并编写一个简单的注册页面,该页面使用PHP/MYSQL 方法进行插入。这是我的代码,但它不起作用!所有路径和代码似乎都是正确的,但它不起作用,让我发疯:(有什么问题吗?
HTML 和 JS:
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>JoinX</title>
<script type="text/javascript">
$(document).ready(function() {
$("#register").click(function() {
var username = $("#username").val();
var password = $("#password").val();
var email = $("#email").val();
var dataString = "username=" + username + "&password=" + password + "&email=" + email + "&insert=";
if ($.trim(username).length > 0 & $.trim(password).length > 0 & $.trim(email).length > 0) {
$.ajax({
type: "POST",
url: "http://127.0.0.1/phonegap/insert.php",
data: dataString,
crossDomain: true,
cache: false,
beforeSend: function() {
$("#register").val('Connecting...');
},
success: function(data) {
if (data == "ok") {
alert("inserted");
$("#register").val('submit');
} else if (data == "error") {
alert("error");
}
}
});
}
return false;
});
});
</script>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<link rel="icon" href="icon.png">
<link rel="stylesheet" href="themes/joinx.min.css" />
<link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role="page" data-theme="a" id="login">
<div data-role="header" data-position="inline">
<h1>Welcome</h1>
</div>
<div data-role="content" data-theme="a">
<p align="center">Don't Have An Account? <a href="#signup" class="ui-link">Register Now!</a>.</p>
<label for="slider1">Username :</label>
<input type="text" name="username2" id="username2" data-theme="Login" />
<label for="slider1">Password :</label>
<input type="password" name="Password2" id="Password2" data-theme="Login" />
<input type="submit" name="login" id="login" value="Login" data-theme="Login" />
</div>
</div>
<div data-role="page" data-theme="a" id="signup">
<div data-role="header" data-position="inline">
<h1>Register A New Account</h1>
</div>
<div data-role="content" data-theme="a">
<p align="center">Already Have An Account? <a href="#login" class="ui-link">Sign In Here!</a>.</p>
<label for="slider1">Username :</label>
<input type="text" name="username" id="username" data-theme="Login" />
<label for="slider1">Password :</label>
<input type="password" name="Password" id="Password" data-theme="Login" />
<label for="slider1">Email Address :</label>
<input type="email" name="email" id="email" data-theme="Login" />
<input type="submit" name="register" id="register" value="Sign Up" data-theme="Sign Up" />
</div>
</div>
</body>
</html>
PHP 页面:
<?php
$servername = "localhost";
$username2 = "root";
$password = "";
$dbname = "joinx";
// Create connection
$conn = new mysqli($servername, $username2, $password, $dbname);
$conn->set_charset("utf8");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} else {
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$q = mysql_query("INSERT INTO `user` (`Username`,`Password`,`Email`) VALUES ('$username','$password','$email')");
if ($q)
echo "ok";
else
echo "error";
}
?>
编辑:我说它不起作用。我的意思是它不会发生任何事情!就像 HTML 静态页面一样...
最佳答案
Cordova PhoneGap 是用于构建混合应用程序的客户端框架。如果我没记错的话,您希望在 PhoneGap 中运行服务器端语言。这个解决方案根本不可能。
关于javascript - 使用 PHP/MYSQL 在 PhoneGap 中注册不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36489812/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!