hiding or showing a div depending on values fetched from a database

Thursday, July 3, 2014


I have a table with a column of registration.When user log's into his/her account,a value of unregistered is inserted into the registration column.The user then proceeds and register his/her account and the value in the registration column is updated to registered.I need to return true when the user is registered and change the value in a particular div from unregistered to registered and hide the registration link to the page for registration using Jquer` as in code three.In addition return false when the user is unregistered.The code one below is functioning when i manually change the id of the user as shown below but when i use the user's id in session as shown in code two,only return false is executed.I need a person to assist me please.The jquery code below is functioning with php code one.




Code one is functioning but the id's i have to change them manually.
**code one**


Code two does not execute. code two



<?php
require'connection.php';//connection to the database
require'user_getfield.php';//function to get user data in session,functioning

if(isset($_GET['register']))
{
$user_id=$_SESSION['user_id'];

$register=mysql_real_escape_string(htmlentities($_GET['register']));

$query="select `account_id` from `user_account` where `register`='$register' and `account_id`='$user_id'";
if($query_run=mysql_query($query)){
$row=mysql_num_rows($query_run);

if($row == 1){
echo 'registered';
}
else if($row== 0){
echo 'unregistered';
}
}
}
?>


Code three below is the jquery code.When a return true is executed,the div value changes from unregistered to registered and the registration link is hidden from the being accessed.


jquery code three $(document).ready(function() { var register='registered';



$.get('php/AjaxFinishRegistration.php',{register:register},function(data)
{
if(data=='registered')
{
$('#welcome_div').html('YOU ARE REGISTERED').css('background','blue');
$('#AccountRegister,#registration').hide();
}
else if(data=='unregistered'){
$('#welcome_div').html('FINISH REGISTRATION').css('background','red');
$('#CreateGig').attr('value','disabled');
}
});
});






http://ift.tt/1qqo8te