Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP Ajax jQuery
I was expecting an ouput but it didn't show any. Is there missing in my code or what's wrong? Thanks in advance
 
I have this line of code in my main page
 
<form>
        <label for="text_email">E-mail:</label>
        <input id="text_email" type="email" >
 
        <script type="text/javascript" charset="utf-8" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js">
            $(document).ready(function(){
                $('#text_email').keyup(function(){
                    email($(this).val());
                });
            });
            function email(str){
                $.post('checkmail.php',{ email: str},
                function(data){
                    $('#check_email').html(data.returnValue);
                }, 'json');
            }
        </script>
 
        <label for="text_email" id="check_email"></label>
    </form>
 
And this line of code
 
<?php
if(isset($_POST['email']))
{
    try
    {
        $pdo=new PDO('mysql:host=localhost;dbname=class;charset=utf-8', 'root');
    }
    catch(PDOException $e)
    {
        echo 'Failed: '.$e->getMessage();
    }
 
    $stmt=$pdo->prepare('SELECT email FROM class where email=:email LIMIT 1');
    $stmt->execute(array(':email'=>$_POST['email']));
    if($stmt->rowCount()>0)
    {
        $check='E-mail cannot be use.';
    }
    else
    {
        $check='E-mail can be use.';
    }
 
    echo json_encode(array('returnValue'=>$check));
}
?>
Posted 27-Aug-12 9:09am
Comments
ryanb31 at 27-Aug-12 15:24pm
   
So, what specific line of code is giving you a problem?
Mohibur Rashid at 29-Aug-12 1:41am
   
first pointer: your src in script tag is wrong. it should be src="http//:ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 235
1 DamithSL 225
2 OriginalGriff 198
3 George Jonsson 170
4 Maciej Los 165
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 27 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100