/    Sign up×
Community /Pin to ProfileBookmark

PHP Ajax verification system

Hello, I need help with a think in my project.
Is in php ajax. I made a login with a verification code. This works in this way when you login a mail is sent to you with a pin code which you have to put in input field and then you can enter your profile. The verification works but when I enter into the profile the profile should show a table but is not. I don’t understand why,. Can you please see my code and tell me what is wrong?? Please.
The line I would like to show is in js number 82 (Show customers).
PHP: [URL=”http://paste.ofcode.org/GA52bW2weSC5iPsUQxt24Z”]http://paste.ofcode.org/GA52bW2weSC5iPsUQxt24Z[/URL]
js: [URL=”http://paste.ofcode.org/cjQm62b8nNTP4xWcqth9Zt”]http://paste.ofcode.org/cjQm62b8nNTP4xWcqth9Zt[/URL]
I have no idea why now is not working anymore.
Thanks for help.

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmMay 05.2015 — Show us the code once again
Copy linkTweet thisAlerts:
@JakubauthorMay 05.2015 — Show us the code once again[/QUOTE]
[code=php]
<?php

header("Content-type: application/json");

require_once 'database.php';

// $aAcconts = array();
// $sql = "SELECT * FROM accounts WHERE customer_id =".$_SESSION['userId'];
// $result = $conn->query($sql);

// if ($result->num_rows > 0)
// {
// while($row = $result->fetch_assoc()){
// $sResult = '{"accountId":"'.$row['id'].'", "type":"'.$row['account_type'].'", "amount":"'.$row['balance'].'", "timestamp":"'.$row['timestamp'].'"}';
// $jResult = json_decode($sResult);

// array_push($aAcconts , $jResult);

// }
// // Create a key named "accounts" in the user
// // object
// $gaData['user']->accounts = $aAcconts;
// // array_push($gaData['user'], $aAcconts);
// echo json_encode($gaData, JSON_PRETTY_PRINT);
// }
// else
// {
// echo '{"status":"error"}';
// }


$sql = "SELECT * FROM accounts";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
// output data of each row
$sFakeArray = "[";
while($row = $result->fetch_assoc()) {
$sFakeArray .= '{"accountId":"'.$row['id'].'", "type":"'.$row['account_type'].'", "amount":"'.$row['balance'].'", "timestamp":"'.$row['timestamp'].'"}';
}
$sFakeArray = substr($sFakeArray, 0, -1);
$sFakeArray .= "]";
//sleep(2);
echo $sFakeArray;
} else {
echo '{"status":"error"}';
}
$conn->close();
?>
[/code]

[code=html]
$("#btnLogin").click(function(){
login();
});


function login(){
var sLoginUserEmail = $("#txtLoginUserEmail").val();
var sLoginUserPassword = $("#txtLoginUserPassword").val();
//console.log(sLoginUserName + " " + sLoginUserPassword);

var sLink = "main-ajax.php?sLoginUserEmail="+sLoginUserEmail+"&sLoginUserPassword="+sLoginUserPassword;
console.log(sLink);
$.get(sLink, function(jData)
{
if(jData.status == "success")
{

$(".container").hide();
$("#signupnavi").hide();
$("#tblAccounts").show();
$("#exampleModal").hide();
$(".logInNav").hide();
$("#signOut").show();
$("#customersNav").show();
$("#transfersNav").show();
$(".verifyClass").fadeIn();


}

});
}

$("#btnVerify").click(function(){
verify();
//accounts();
});

function verify(){
//var sVerify = $("#txtVerify").val();
//sLink = "ajax-verify.php?sVerify="+sVerify;
//$.get(sLink, function(jData){

alert("hallo from verify");
//accounts();
$(".verifyClass").hide();

//$("#wdw-welcome").show();
//$("#lblUserName").text(jData.user.userName);
//showAccounts(jData);


//});

}

$.get("ajax-account.php", function(jData){
showAccounts();
});

/*

function accounts(){
alert("hallo");
sLink = "ajax-account.php";
console.log(sLink);
$.get(sLink, function(jData){
console.log(jData);
alert("hallo from account");

//$("#wdw-welcome").show();
//$("#lblUserName").text(jData.user.userName);

showAccounts(jData);

});

}

*/

function showAccounts(jData)
{
$("#tblAccounts").empty();
for(var i = 0; i < jData.length; i++){

var sRow = '<tr><th scope="row" class="text-center">'+jData[i].accountId+'</th><td class="text-center">'+jData[i].type+'</td><td class="text-center">'+jData[i].amount+'</td><td class="text-center">'+jData[i].timestamp+'</td><td class="text-center"><span class="glyphicon glyphicon-envelope"></span><td class="text-center"><span class="glyphicon glyphicon-phone"></span><td class="text-center"></td></tr>';
$("#tblAccounts").append(sRow);
}


}
[/code]
Copy linkTweet thisAlerts:
@ginerjmMay 05.2015 — I see nothing here that seems to relate to your question. Where is the table? Where is the html?
Copy linkTweet thisAlerts:
@JakubauthorMay 05.2015 — I see nothing here that seems to relate to your question. Where is the table? Where is the html?[/QUOTE]
So this is all what I have but was too long to put in the tags so there is a link

http://paste.ofcode.org/8pK5vZn7WqNgVC9zBhBvfa
Copy linkTweet thisAlerts:
@JakubauthorMay 05.2015 — By the way the table rows are generated from ajax/jq and for now is not working. If is need it I can post all my project but will be better in a zip file because is big to post all the code here. If you need it just ask and I will send you.

Thanks
Copy linkTweet thisAlerts:
@rootMay 05.2015 — The forum accepts large posts, you wrap in forum tags and if its too big for one post, make two or more! Simples!
Copy linkTweet thisAlerts:
@ginerjmMay 05.2015 — Since I'm not a jquery kinda guy, I can't help you out. Your post was entitled ajax, so I simply assumed your problem was with the client/server interface with php. Perhaps you s/b posting in a js jq forum instead?
Copy linkTweet thisAlerts:
@JakubauthorMay 05.2015 — I posted to the jquery section
×

Success!

Help @Jakub spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...