-1

check this out.

  <?php
   include('configdb.php');
   if(isset($_POST['submit'])) {
    $email = trim($_POST['email']);
    $password = trim($_POST['password']);
    $query = "SELECT * FROM user WHERE email='$email' AND password='$password' AND com_code IS NULL";
    $result = mysqli_query($mysqli,$query)or die(mysqli_error());
    $num_row = mysqli_num_rows($result);
    $row = mysqli_fetch_array($result);

      if( $num_row == 1 ) {
        $_SESSION['user_name']=$row['username'];
        header("Location: member.php");
        exit;
      }

      else {
  ?>
      <script type="text/javascript">
        $('.error').append('This will display if there was an error');
      </script> 
  <?php      
      }
    }
  ?>

<div data-role="content" data-theme="b"><p class="error"></p></div>

So as a newbie dev I'm playing around and trying to figure out why certain things work and why other's don't.

The idea here is that if the database check fails jQuery injects a message into the paragraph tag with the class of error. (You can't do that with PHP echo can you?)

Works great until I add the jQuery Mobile framework. Then all it does is refresh and nothing updates. I can't figure out why the Mobile framework is preventing this from happeneing.

Any advice would be appreciated. Thanks guys.

AfricanMatt
  • 145
  • 1
  • 9

1 Answers1

0

Why can't you use PHP to do it? It looks pretty trivial:

<?php if (isset($num_row) && $num_row == 0) { ?>
  <div data-role="content" data-theme="b">
    <p class="error">This will display if there was an error</p>
  </div>
<?php } ?>
billyonecan
  • 20,090
  • 8
  • 42
  • 64