Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Cannot login as specific page

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Cannot login as specific page

Postby st3vi3 » Wed Jun 05, 2013 7:45 pm

Hi guys. I'm newbie here and newbie in php language as well. :D

I try to create (using localhost) a new login page using 3 users which is, 3 users group (admin, staff, user). I also create 3 difference user interface for that users. For my concern, I don't need drop down menu/button to select user group to login at the first login page for another purpose.

For example, if I want to login as admin, I just set my username and password to login and direct to admin/admin_screen.php........

Example php coding attach below.

Code: Select all
<form method="POST"
<?php
$username = "";
$sql = sqlStatement("SELECT * FROM users WHERE username = '". $username ."'");
$row = sqlFetchArray($sql);
$result[0] = $row;
$user = $result[0]{"user_group"};

if ($user=="1")
{
   $addurl = "../admin/admin_screen.php?auth=login&site=";
}
else if ($user=="2")
{
   $addurl = "../staff/staff_screen.php?auth=login&site=";
}
else if ($user=="3")
{
   $addurl = "../user/user_screen.php?auth=login&site=";
}

?>
 action="<?php echo $addurl . htmlspecialchars($_SESSION['site_id']); ?>"
 target="_top" name="login_form" onSubmit="return imsubmitted();">


example.jpg
After click button submit login, this error occur. This page not direct into my specific address in if....else statement
example.jpg (59.21 KiB) Viewed 731 times


Can anyone expert help in this problem? :help:

Apologize with my word and language. :oops:

Thanks guys.
newbie st3vi3
User avatar
st3vi3
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jun 05, 2013 7:09 pm

Re: Cannot login as specific page

Postby Parrot » Wed Jun 05, 2013 7:58 pm

The way you've got this login system set up seems a bit strange to me, I'm having trouble understanding how you're trying to work this. Apparently you've already got they're username and you're asking them to submit a form to determine where they go from here?

In your browser when it's displaying this login form, view the page source and tell me what it's showing after action="
Parrot
New php-forum User
New php-forum User
 
Posts: 9
Joined: Mon Oct 01, 2012 10:17 pm

Re: Cannot login as specific page

Postby johnj » Wed Jun 05, 2013 8:04 pm

1). breaking the form tag as you have did is not required. you can start the <form tag just before the word "action".

2). Please print this, echo $addurl . htmlspecialchars($_SESSION['site_id']) and decide if it is using the correct url to proceed after login.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Cannot login as specific page

Postby st3vi3 » Wed Jun 05, 2013 8:37 pm

Parrot wrote:The way you've got this login system set up seems a bit strange to me, I'm having trouble understanding how you're trying to work this. Apparently you've already got they're username and you're asking them to submit a form to determine where they go from here?

In your browser when it's displaying this login form, view the page source and tell me what it's showing after action="


Thanks Parrot for the quick reply,

I'm sorry if I gave you the confusion. I'm also don't get what are you try to state with this statement Apparently you've already got they're username and you're asking them to submit a form to determine where they go from here?? Is it about this sql statement
Code: Select all
$sql = sqlStatement("SELECT * FROM users WHERE username = '". $username ."'");
? :?

It's not showing anything on action=" and action itself not appear in view page source.
error.jpg
error.jpg (98 KiB) Viewed 722 times
User avatar
st3vi3
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jun 05, 2013 7:09 pm

Re: Cannot login as specific page

Postby Parrot » Wed Jun 05, 2013 8:42 pm

I need to see the page source for the page with your login form, not the "object not found" page.
Parrot
New php-forum User
New php-forum User
 
Posts: 9
Joined: Mon Oct 01, 2012 10:17 pm

Re: Cannot login as specific page

Postby st3vi3 » Wed Jun 05, 2013 9:12 pm

johnj wrote:1). breaking the form tag as you have did is not required. you can start the <form tag just before the word "action".

2). Please print this, echo $addurl . htmlspecialchars($_SESSION['site_id']) and decide if it is using the correct url to proceed after login.


Thanks johnj,
1). Which means like this?
Code: Select all
<?php
$username = "";
$sql = sqlStatement("SELECT * FROM users WHERE username = '". $username ."'");
$row = sqlFetchArray($sql);
$result[0] = $row;
$user = $result[0]{"user_group"};

if ($user=="1")
{
   $addurl = "../main/main_screen.php?auth=login&site=";
}
else if ($user=="2")
{
   $addurl = "../main_doc/main_screen.php?auth=login&site=";
}
else if ($user=="3")
{
   $addurl = "../main_front/main_screen.php?auth=login&site=";
}

?>
<form method="POST"
 action="<?php echo $addurl . htmlspecialchars($_SESSION['site_id']); ?>"
 target="_top" name="login_form" onSubmit="return imsubmitted();">

I have try this code but it same like before as well.

2). I have try to change $username = "admin"; and it can be login as usual, but it just login admin page only. If I login as another users like staff or user, it just direct to admin page as well, not page (UI) staff or user. I don't know what is the problem. It's problem after I change $username = "";.

Thanks for the help Mr. johnj :)
User avatar
st3vi3
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jun 05, 2013 7:09 pm

Re: Cannot login as specific page

Postby st3vi3 » Wed Jun 05, 2013 9:22 pm

Parrot wrote:I need to see the page source for the page with your login form, not the "object not found" page.


Hi Parrot,

Sorry if I u get anger with me. Really sorry.... :(

Here is the page source.
login.jpg
login.jpg (78.44 KiB) Viewed 717 times


Thanks
User avatar
st3vi3
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jun 05, 2013 7:09 pm

Re: Cannot login as specific page

Postby Parrot » Wed Jun 05, 2013 10:53 pm

I'm not angry with you.

What you're showing me here is the page source for the main frame. Could you show me the page source for the login frame?
Parrot
New php-forum User
New php-forum User
 
Posts: 9
Joined: Mon Oct 01, 2012 10:17 pm

Re: Cannot login as specific page

Postby johnmacd » Thu Jun 13, 2013 10:30 pm

Check your admin file path.
johnmacd
New php-forum User
New php-forum User
 
Posts: 19
Joined: Wed Jun 12, 2013 9:30 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.