php - Display error messages from serverside through javascript -


i have 3 files in total. login.html - login.js - login.php

function login(){     $(document).ready(function(){         var epost = document.getelementbyid("epost").value;         var passord = document.getelementbyid("passord").value;         $.ajax({             type: 'post',             url: 'login.php',             data: "epost=" + epost + "&passord=" + passord,             success: function(result){             }         });     }); } 

here php-file:

<?php  require 'db.php'; session_start();  if(!$_post['epost'] || !$_post['passord']){     echo "type in username , password"; } else{     $stmta = $dbo->prepare("select * kunde epost = ?");      $stmta->execute(array($_post['epost']));     $login = $stmta->fetch();      if(empty($login)){         echo "user not exist";     }     else {         $passord_db = $login['passord'];             $passord = md5($_post['passord']);                if($passord_db != $passord){                         echo "invalid password";         }         else{             $active = $login['active'];                  $epost = $login['epost'];                     if($active == 0){                 echo "activate account ($epost) ";             }             else{                 $_session['epost'] = $epost;             }         }     } } ?> 

this may silly question, appologize in advance, how can these error-messages shown through js-script instead of php-script?

in javascript have success property function(result) variable result contain output printed php file. can use javascript inject output (error messages) anywhere in html.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

node.js - Bad Request - node js ajax post -

uitableview - Create and use custom prototype table cells in xamarin ios using storyboard -