Login Cp problem.

i having a 2 login section for 2 type of different user login… Jobseeker and employer…
[SIZE=“2”]This login code if for jobseeker[/SIZE]

[PHP]<?php include("function.php"); ?>

<?php if(isset($_SESSION['username'])) { echo "
Hello, ".$_SESSION['username'].".

"; include("ucp.php"); echo " "; } else { if(!isset($_POST['login_x'])){ echo " Username: Password:

"; } else { $username = $_POST['username']; $password = $_POST['password']; if ($username&&$password) { $conn = mysql_connect("localhost","root","") or die ("Cannot connect!"); mysql_select_db("job_seeks") or die("cannot find the db"); $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $query = mysql_query("SELECT * FROM employee_user WHERE username='$username'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } if ($username==$dbusername&&$password==$dbpassword) { $_SESSION['username']=$dbusername; } echo ""; } else { echo "
The username or password is incorrect. Please try again.
You will be redirected in 3 seconds

"; } } } } ?>[/PHP]

[SIZE=“2”]And this code is for employer login[/SIZE]

[PHP]

<?php if(isset($_SESSION['username'])) { echo "
Hello, ".$_SESSION['username'].".

"; include("ecp.php"); echo " "; } else { if(!isset($_POST['login_x'])){ echo " Username: Password:

"; } else { $username = $_POST['username']; $password = $_POST['password']; if ($username&&$password) { $conn = mysql_connect("localhost","root","") or die ("Cannot connect!"); mysql_select_db("job_seeks") or die("cannot find the db"); $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $query = mysql_query("SELECT * FROM employer_user WHERE username='$username'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } if ($username==$dbusername&&$password==$dbpassword) { $_SESSION['username']=$dbusername; } echo ""; } else { echo "
The username or password is incorrect. Please try again.
You will be redirected in 3 seconds

"; } } } } ?>[/PHP]

[SIZE=“2”]ok now i explain whats the problem here. This my login page for both side looks like[/SIZE]

[SIZE=“2”]Now i already set the login detail for the jobseeker at database and its different login detail with employer. When i login for the jobseeker this will appear. [/SIZE]

Hello aquilina,

Perhaps what your problem is, is that you use the same session name for two different data pieces.
[php]if(isset($_SESSION[‘username’])) [/php]
Rename these to for instance usernameSeeker and usernameEmployer.

This should solve your what I believe is your problem, if not please give more information about the problem.

i already rename and it solved the appear of cp at the both login but now i faced another problem… when i login for jobseeker, it will appear this http://prntscr.com/4espn at sidebox of employer for 3sec then then error message will disappear again… And when i login for employer, it also will appear this http://prntscr.com/4esqc at jobseeker sidebox login … it also appear for 3sec then its will gone… any idea whats wrong?

This is because he can’t find the username/username_job in the session array(undefined index).
You can solve this by either setting the opposite session to false:
[php]
$_SESSION[‘username’] = $dbusername;
$_SESSION[‘username_job’] = false;[/php]
Or by checking it in a different way:
[php]if(isset($_SESSION[‘username’]))[/php]

This must solve your problem, if you have any further issues let me know.

where should i put the code? i mean in which line?

Sorry I made a mistake what I told you, you already have. the undefined index is from another array.
It comes from the $_POST[‘username’]
change this code:
[php]$username = $_POST[‘username’];
$password = $_POST[‘password’];[/php]
to this:
[php]
if(isset($_POST[‘username’])
$username = $_POST[‘username’];
if(isset($_POST[‘password’])
$password = $_POST[‘password’];
[/php]

ok it give me this http://prntscr.com/4evht … see the ss…

Can you also please rename the login_x for both forms to login_employer and login_seeker or something(also rename this in the $_POST[‘login_x’] check)

when i put this code
[php]if(isset($_POST[‘username’])
$username = $_POST[‘username’];
if(isset($_POST[‘password’])
$password = $_POST[‘password’];[/php]

it said [php]Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\sources\login\login.php on line 39[/php]

[php]if(isset($_POST[‘username’]))
$username = $_POST[‘username’];
if(isset($_POST[‘password’]))
$password = $_POST[‘password’];[/php]
forgot to close the first “(” also please make the change I told in the previous post, then this shouldn’t be needed anymore

then this code didnt need anymore? and use the original one?

[php]
$username = $_POST[‘username’];
$password = $_POST[‘password’];[/php]
Is correct.
[php]if(!isset($_POST[‘login_x’])){[/php]
Is incorrect replace it with login_employer/login_seeker
Also change:
[php]
<input type=“image” src=“images/login.png” name=“login” value=“Login” alt=“login” />[/php]
to what you change the post var into(name is only needed)

when i change the
[php]if(!isset($_POST[‘login_x’])){[/php]
to
[php]if(!isset($_POST[‘login_jobseeker’])){[/php]
when i tried to login theres nothg happen… its just keep refreshing the login sidebox…

and this code what did u mean by change the post var into(name is only needed)
[php]<input type=“image” src=“images/login.png” name=“login” value=“Login” alt=“login” />[/php]

[php]<input type=“image” src=“images/login.png” name=“login” value=“Login” alt=“login” />[/php]

should be

[php]<input type=“image” src=“images/login.png” name=“login_jobseeker” value=“Login” alt=“login” />[/php]

haha i found it already… i just changed this for the employer
[php]if(!isset($_POST[‘login_x’])){[/php]
to this
[php]if(!isset($_POST[‘login2_x’])){[/php]

And for this one
[php]<input type=“image” src=“images/login.png” name=“login” value=“Login” alt=“login” />[/php]
i changed to this
[php]<input type=“image” src=“images/login.png” name=“login2” value=“Login” alt=“login2” />
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service