问题在php中链接jquery移动数据角色页面

时间:2016-04-23 01:07:10

标签: php html5 jquery-mobile

有谁可以告诉我为什么我无法链接到<div data-role="page" id="sessionrecordsuccess">文件中的数据角色页面main.php?相反,当执行php文件时,它将我引导到main.php的顶部我有另一个php文件,它链接到同一个HTML文件中的另一个数据角色完全正常,我检查了任何语法错误,所以不知道为什么不是这个?

record_session.php

<?php

$servername = "";
$username = "";
$password = "";

$con=mysqli_connect('','','','');
// This code creates a connection to the MySQL database in PHPMyAdmin named 'ibill':

if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// The connection is then checked, if it fails, an echo is sent back to the page stating a connection error.

if(!empty($_POST)) 
{
    $typeofactivity = $_POST['typeofactivity'];
    $employer = $_POST['employer'];
    $date = $_POST['date'];
    $time = $_POST['time'];
    $amount = $_POST['amount'];
    $errorMessage = "";

    if(empty($typeofactivity)) {
      $errorMessage .= "<li>You forgot to enter an activity!</li>";
    }
    if(empty($employer)) {
      $errorMessage .= "<li>You forgot to enter an employer!</li>";
    }
    if(empty($date)) {
      $errorMessage .= "<li>You forgot to select the date!</li>";
    }
    if(empty($time)) {
      $errorMessage .= "<li>You forgot to select the time!</li>";
    }
    if(empty($amount)) {
      $errorMessage .= "<li>You forgot to select the amount of the session!</li>";
    }

    $record_session = "INSERT INTO session_details (typeofactivity, employer, date, time, amount) VALUES ('$typeofactivity', '$employer', '$date', '$time', '$amount')";
    mysqli_query($con, $record_session);
}

/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

header('Location: main.php#sessionrecordsuccess');
exit();
?>

main.php#sessionrecordsuccess

<!--********************************RECORD SESSION PAGE SUCCESS************************************-->
<!--***************************************************************************************-->

<!--********************************HEADER**********************************************-->
<div data-role="page" id="sessionrecordsuccess">
    <div data-role="header" data-id="foo1" data-position="fixed">
    <div class='cssmenu'>
      <ul>
        <li class='active'><a href='#home'>Home</a></li>
        <li><a href='#sessionrecord'>Record a Session</a></li>
        <li><a href='#viewsessions'>View Sessions</a></li>
        <li><a href='#email'>E-mail an Invoice</a></li>
      </ul>
    </div>
  </div><!-- /header -->
<!--********************************HEADER**********************************************-->

<!--********************************MAIN**********************************************-->
  <div data-role="main" class="ui-content">

    <img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">

        <section class="maincontent">
          <h1>Record a session using the form below</h1>
            <P>Session logged successfully! <br>Record another...</p>
            <form method="post" action="record_session.php" id="sessionRecord">
              <fieldset>
                  <select name="typeofactivity" id="typeofactivity" data-native-menu="false">
                    <option>Type of Session</option>
                    <option value="Surf">Surf</option>
                    <option value="Coasteer">Coasteer</option>
                    <option value="Bodyboard">Bodyboard</option>
                    <option value="Cornish Challenge">Cornish Challenge</option>
                  </select>
              </fieldset>
              <fieldset>
                  <select name="employer" id="employer" data-native-menu="false">
                    <option>Employer</option>
                    <option value="Newquay Activity Centre">Newquay Activity Centre</option>
                    <option value="Coastline Coasteer">Coastline Coasteer</option>
                  </select>
              </fieldset>
                  <label for="date">Date of Session</label>
                  <input type="date" data-clear-btn="false" name="date" id="date" value="">

                  <label for="time">Time of Session</label>
                  <input type="time" data-clear-btn="false" name="time" id="time" value="">                  

                  <label for="amount">Amount (GBP)</label>
                  <input type="number" data-clear-btn="true" name="amount" id="amount" value="">
                <div id="submitbutton">
                  <input type="submit" name="formSubmit" value="Submit">
                </div>
            </form>

        </section>
  </div>
<!--********************************MAIN**********************************************-->

<!--********************************FOOTER**********************************************-->
  <div data-role="footer">
    <footer class="footer">
        <p>awilliams&copy;</p>
    </footer>
  </div>
</div>
<!--********************************FOOTER**********************************************-->

<!--********************************END OF RECORD SESSION PAGE SUCCESS************************************-->
<!--***************************************************************************************-->

1 个答案:

答案 0 :(得分:0)

我刚刚设法弄清楚了,但我想我会回答其他人可以看到的。我错过了表单标记中的data-ajax="false属性。