0
我正在使用JavaScript/HTML和一点点Jquery作为使用PhoneGap/Cordova进行测试的应用程序。登录后显示登录用户名? (PHP/JavaScript/HTML)
我想要做的是在用户登录后在所有页面上显示用户名,我相信最好避免使用JavaScript,因此我最好喜欢使用PHP。
有人能帮我一下,告诉我该怎么办?
请参阅下面我的代码的不同部分,可能对您有所帮助。
登录功能:
function loginDB(tx)
{
var Username = document.getElementById("username").value;
var Password = document.getElementById("password").value;
tx.executeSql("SELECT * FROM SoccerEarth WHERE UserName='" + Username + "' AND Password= '" + Password + "'", [], renderList);
}
function renderList(tx,results) {
if (results.rows.length > 0) {
navigator.notification.alert("You are in!");
$(":mobile-pagecontainer").pagecontainer("change", "#page4");
}
else
{
navigator.notification.alert("Incorrect Password, Please try again!");
$(":mobile-pagecontainer").pagecontainer("change", "#page3");
}
}
HTML页面例子:
<div data-role="page" id="page4" data-theme="d">
<div data-role="header">
<a href="#page1" class="ui-btn ui-icon-home ui-btn-icon-left">Sign Out</a>
<h1>SoccerMeet</h1>
</div>
<div data-role="main" class="ui-content">
<ul data-role="listview" data-inset="true">
<li>
<a href="#page5" data-transition="slide">
<img src="images/icon1.jpg">
<h2>Search Soccer Events</h2>
<p>Find soccer meets near you</p>
</a>
</li>
<li>
<a href="#page6" data-transition="slide">
<img src="images/icon2.png">
<h2>Create an Event</h2>
<p>Have an event you would like to invite people to?</p>
</a>
</li>
<li>
<a href="#page5" data-transition="slide">
<img src="images/icon4.png">
<h2>Help Center</h2>
<p>FAQ's and further guidance on the app</p
></a>
</li>
<li>
<a href="#page1" data-transition="slide">
<img src="images/icon3.png">
<h2>Settings</h2>
<p>Make changes to the app</p
></a>
</li>
<li>
<a href="#page1" data-transition="slide">
<img src="images/icon5.png">
<h2>The Team</h2>
<p>Meet the team behind the app, the co-founders, developers etc.</p
></a>
</li>
</ul>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#page1" data-icon="user">Profile</a></li>
<li><a href="#page1" data-icon="location">Find Events</a></li>
<li><a href="#" data-icon="calendar">Calendar</a></li>
<li><a href="#" data-icon="info">Help Center</a></li>
<li><a href="#page7" data-icon="camera">Camera</a></li>
</ul>
</div>
</div>
</div>
感谢您的链接,但是我很努力地看到我能如何适应我的html页面。你能提供更多的帮助吗? – Mahdi
伙计们...他发布的是普通网站的答案。 Cordova/PhoneGap没有能够运行php的服务器。你需要通过ajax(jquery)运行php脚本。在应用程序(phonegap/cordova)中直接运行PHP **不是**可能的 – Sithys
我不明白是谁下了这个,它只关心你使用的平台,你使用的cardova phonegap build来打包你的应用程序进行测试。多平台,但是你的问题是登录需求的实现不仅仅是php或者html,现在我所提供的是一个auth登录的例子,你将如何在登录后能够在导航栏中显示用户名。问题不清楚,你想用户访问auth登录?或者你想知道如何通过SQL或Apache来实现?或者你想要使用cardova phonegap build! – Hashes