2014-02-07 34 views
0

我有三個文件。 1. login.html - 這將採取用戶憑據並將它們發送到php腳本。 2. check_password.php - 這將驗證對MySQL數據庫的用戶憑據。 3. location.html - 這將顯示使用谷歌地圖的位置。加載一個.php頁面,其中應包含一些.php文件的數據

問題在於整合這三個文件。

對於有效的用戶,應該加載location.html。

location.html應該是這個樣子的瀏覽器 第一部分 - 歡迎「用戶名」 第2部分 - 地圖

爲了實現location.html的第一部分,我猜,我應該得到的來自check_password.php的用戶名。我是一名初學者。我不明白我該如何做到這一點。請幫忙。如果我需要提供任何其他信息,請告訴我。

location.html:

<!DOCTYPE html> 
<html> 
    <head> 
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
    <style type="text/css"> 
     html { height: 75%; } 
     body { height: 75%; ; margin: 0; padding: 0 } 
     #map-canvas { height: 80%; width: 80%; margin: 10px } 
    </style> 
</head> 

    <script type="text/javascript" 
     src="https://maps.googleapis.com/maps/api/js?key=#######&sensor=true"> 
    </script> 
<script type="text/javascript"> 
    /*code for initialising map*/  
    </script> 
body> 
    <div id="map-canvas"/> 
    </body> 
</html> 

我能夠完成這個整合的某些部分。我可以將數據從login.html發送到php腳本進行驗證。

回答

3
  1. 的login.html應該包含將數據提交check_password.php
  2. check_password.php應該認證用戶,並標記它們在使用會話
  3. location.html應該是一個PHP登錄表單程序並檢查會話數據是否在交付私有HTML之前指明已通過身份驗證的用戶
+1

要添加:'login.html'可以(應該)是一個PHP程序,用於檢查用戶是否已經登錄,如果是,立即重定向到'location.html'。如果登錄失敗,它還應提供一些反饋,並且您必須將用戶重定向回登錄表單。 – AmazingDreams

+0

因爲我是初學者,我不知道會話是如何工作的。你可以幫我用check_password.php的代碼來標記用戶已經登錄了,也可以用上面的part3來標記。 – user2063635

+0

http://php.net/manual/en/session.examples.basic.php – Quentin

相關問題