Page 1 of 1

Reload after login

Posted: Mon Jan 11, 2010 7:23 am
by Jay87
Currently once you login you get re-directed to the 'mycalls.php' page but you can click the 'home tab' which shows the login page (even though you are logged in)- see below:

Image

basically what i want to do is once the user has logged in i want it to re-load the 'home tab' to show the details of the 'my calls' page.... SO this would appear instead of the login boxes

Image

Any ideas on how i could do this?

I could post the current code for the home (login) page but it's 100 lines...

Any help would be greatly appreciated

Re: Reload after login

Posted: Mon Jan 11, 2010 8:36 am
by Jay87
Anyone got any ideas as i am totally stuck?

Re: Reload after login

Posted: Mon Jan 11, 2010 9:08 am
by Charles256
instead of redirecting to mycalls.php redirect home.php?

Re: Reload after login

Posted: Mon Jan 11, 2010 9:44 am
by Jay87
home.php shows:

Image

hence i want to re-load the same page once the user has logged in that is identical to mycalls.php

no idea how too though?

Re: Reload after login

Posted: Mon Jan 11, 2010 9:59 am
by aravona
why do you want your home page to become identical to another page on your site?
This seems a bit odd to me, why not just have your login elsewhere, and then have your homepage as something more like a standard homepage?

If my slightly tired brain is getting this right:

currently:
login - go to page 1 - go to home, tries to get you logged in again?

you want:
login - shows page 1 info on home page?

Are you using a session to log in?

Sure then you can use and IF statement to control which homepage you show.... IF not logged in then home1.php IF users login is valid and logged in show home2.php ? Not exactly tidy but I'm sure it would get the job done, I've done it before for a uni project but it was very simple and directed to a new page that showed this text or this text.

If you're working with frames it should redirect really easily.

Re: Reload after login

Posted: Mon Jan 11, 2010 10:01 am
by Jay87
aravona wrote:why do you want your home page to become identical to another page on your site?
This seems a bit odd to me, why not just have your login elsewhere, and then have your homepage as something more like a standard homepage?
because once i get the current content from mycalls.php onto the home page (after login) i am going to change the content that is on mycalls.php to show all the 1st line calls.....

Just the order i am trying to do it in!

Re: Reload after login

Posted: Mon Jan 11, 2010 10:04 am
by Jay87
aravona wrote:
currently:
login - go to page 1 - go to home, tries to get you logged in again?

you want:
login - shows page 1 info on home page?

Are you using a session to log in?

Sure then you can use and IF statement to control which homepage you show.... IF not logged in then home1.php IF users login is valid and logged in show home2.php ? Not exactly tidy but I'm sure it would get the job done, I've done it before for a uni project but it was very simple and directed to a new page that showed this text or this text.

If you're working with frames it should redirect really easily.
here's the code for the home page currently:

<?
include 'header.htm';
if (!isset($_POST['user'])){$_POST['user']=NULL;}
if (!isset($_GET['err'])){$_GET['err']=NULL;}
if ($_POST['user']!=NULL)
{
if ($_POST['user']=="" || $_POST['pass']==""){header("location: index.php?err=1");exit(0);}
//Check for Contact Login first...
include 'dbcon.php';

$result = mssql_fetch_array(mssql_query("SELECT id,(forename + ' ' + surname) as contact,company FROM contact WHERE username='" . $_POST['user'] . "' AND PWDCOMPARE('" . $_POST['pass'] . "',password)=1",$db));

//Check if the user is a customer
if ($result!=NULL){
$_SESSION['user'] = $result['contact'];
$_SESSION['guid'] = $result['id'];
$_SESSION['level']=1;
$_SESSION['rights']=3;
$_SESSION['pfx'] = "C" . date('Y');
$_SESSION['conts'] = array ($result['id']);
} else {
//If not, Check Engineers list
$ad = ldap_connect("ldap://" . getParam("ad_server"));
if (ldap_bind($ad,getParam("domain") . "\\" . $_POST['user'],$_POST['pass']))
{
//Search for charlton engineer (CNE)
$attributes = array("cn","objectGUID","directReports");
$result = ldap_search($ad, getParam("engineers"), "(saMAccountName=" . $_POST['user'] . ")", $attributes);
if (ldap_count_entries($ad,$result)==0)
{
//if not charlton engineer, are they a customer based engineer (CBE)
$result = ldap_search($ad, getParam("offsite_eng"), "(saMAccountName=" . $_POST['user'] . ")", $attributes);
if (ldap_count_entries($ad,$result)==0)
{
//no user found, reject logon
echo "Cannot logon!";
exit(0);
}
//Set level to CBE
$_SESSION['level']=3;
} else {
//Set level to CNE
$_SESSION['level']=10;
}
//Save other engineers attributes to the session cookie
$entry = ldap_get_entries($ad, $result);
$single_entry = ldap_first_entry($ad, $result);
$guid = ldap_get_values_len($ad, $single_entry, 'objectguid');
$_SESSION['user']=$entry[0]['cn'][0];
$_SESSION['guid']=convertGUID($guid[0]);
$_SESSION['pfx'] = "C" . date('Y');
$_SESSION['conts']=array ();
$_SESSION['rights'] = mssql_result(mssql_query("SELECT rightsmask FROM engineer WHERE id='" . $_SESSION['guid'] . "'",$db),0,0);
$_SESSION['defsearch'] = mssql_result(mssql_query("SELECT defsearch FROM engineer WHERE id='" . $_SESSION['guid'] . "'",$db),0,0);
$_SESSION['conts'] = split(",",mssql_result(mssql_query("SELECT customers FROM engineer WHERE id='" . $_SESSION['guid'] . "'",$db),0,0));

ldap_unbind($ad);
} else {
header("location: index.php?err=1");
exit(0);
}
}
if (isset($_POST['callid'])){
header("location: viewcall.php?id=" . $_POST['callid'] . "&pfx=" . $_POST['callpfx']);
exit(0);
}
header("location: index.php" . $_SESSION['defsearch']);

}


?>
<form action='index.php' method='post'>
<? if (isset($_GET['callid'])){ echo "<input type='hidden' name='callid' value='" . $_GET['callid'] . "'/>";}?>
<? if (isset($_GET['callpfx'])){ echo "<input type='hidden' name='callpfx' value='" . $_GET['callpfx'] . "'/>";}?>
<table cellspacing=0 cellpadding=0 width=100% height=100%><tr><td valign=top align=center><img src='images/login.jpg' alt='Login'></td></tr>
<tr><td>&nbsp;</td></tr>
<tr ><td valign=top align=center>

<table cellspacing=0 cellpadding=0 height=5 border=0 width=300>
<? if ($_GET['err']==1){
echo " <tr><td align=center><font color=red>Incorrect Username or Password</td></tr>";
echo " <tr><td>&nbsp;</td></tr>";
}?>
<tr><th class='overhead_cell' style="border-right:0px;">Enter Credentials</th></tr>
<tr><td class='std_disp_entry_btm'>
<table cellpadding=5 cellspacing=0 width=100%>
<tr><td align=right style="padding-right:5px;"><font face='Arial' size=2 color=909098><b>Username: </td><td><input onkeypress="if (window.event.keyCode==13)submit();" type='input' name='user'></td></tr>
<tr><td align=right style="padding-right:5px;"><font face='Arial' size=2 color=909098><b>Password: </td><td><input onkeypress="if (window.event.keyCode==13)submit();" type='password' name='pass'></td></tr>
</table>
</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td colspan=2 align=center><button class=flat onclick="submit();">Login</button></td></tr>
</table>
</td></tr>
<tr><td height=10>&nbsp;</td></tr>
<tr valign=top height=100%><td align=center><font size=2>If you have forgotten your login details please send an email to:<br><a href='mailto:helpdesk@charltonnetworks.co.uk'>helpdesk@charltonnetworks.co.uk</a></td></tr>
<tr valign=bottom><td align=right><font size=0.5>1.3</font></td></tr>
</table>
</form>
<?
include 'footer.htm';
?>

-----------------------------------------------------------

If that makes it any clearer?

Re: Reload after login

Posted: Wed Jan 13, 2010 3:50 am
by Jay87
Anyone got any ideas on this?? As its 48 hours on and i am still totally stuck!

:(