In my php below i have a forgot password thing and it echo's a form depending on certain conditions how would i style this with my css? because i do not want the forms showing up without any styling
I have tried and tried to figure out what to do but there has been nothing. i even tried thinking about making this into a few serate pages but got confused and lost
<?php
require("core/dbc.php");
if(isset($_GET['code']))
{
$get_username = $_GET['username'];
$get_code = $_GET['code'];
$query = mysql_query("SELECT * FROM users WHERE username='$get_username'");
while($row = mysql_fetch_assoc($query))
{
$db_code = $row['passreset'];
$db_username = $row['username'];
}
if($get_username == $db_username && $get_code == $db_code)
{
echo "
<form action='pass_reset_complete.php?code=$get_code' method='POST'>
Enter A New Password<br><input type='password' name='newpass'><br>
Re-Enter Your New Password<br><input type='password' name='newpass1'><p>
<input type='hidden' name='username' value='$db_username'>
<input type='submit' value='Update Password'>
</form>
";
}
}
if(!isset($_GET['code']))
{
echo "
<form action='forgot_pass.php' method='POST'>
Enter Your Username<br><input type='text' name='username'><p>
Enter your email<br><input type='text' name='email'><p>
<input type='submit' value='Submit' name='submit'>
</form>
";
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$email = $_POST['email'];
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$numrow = mysql_num_rows($query);
if($numrow!=0)
{
while($row = mysql_fetch_assoc($query))
{
$db_email = $row['email'];
}
if($email == $db_email)
{
$code = rand(10000,1000000);
$to = $db_email;
$subject = "Password Reset";
$body = "
This is a automated email. PLEASE DO NOT REPLY TO THIS MESSAGE
Click the link below or paste it into your browser
http://localhost:8080/signup-project/signup-project/registration%20and%20login/forgot_pass.php?code=$code&username=$username
";
mysql_query("UPDATE users SET passreset='$code' WHERE username='$username'");
mail($to,$subject,$body);
echo "Check Your Email For Your New Password";
}
else
{
echo "the email is incorrect";
}
}
else
{
echo "that username does not exist";
}
}
}
?>
Ok i am confused because a lot of people are saying different ways so let me try this i am going to put my css file code then i am going to paste my log in form code (where i have this css working'
this is the code from my .css file
body {
line-height: 1.4;
background-color: #666;
font-family: Arial, Helvetica, sans-serif;
}
h1 {
font-family: 'Roboto', sans-serif;
}
.hidden {
display: none;
}
a,
a:active,
a:focus
a:visited {
color: #1B9BE0 ;
text-decoration: none;
}
a:hover {
text-decoration: underline
}
/* Structure */
#wrap {
width: 960px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
-webkit-box-shadow: 1px 1px 5px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 1px 1px 5px rgba(50, 50, 50, 0.75);
box-shadow: 1px 1px 5px rgba(50, 50, 50, 0.75);
}
#head {
text-align: center;
}
.form-wrap {
width: 600px;
margin: 0 auto;
}
.content {
overflow: hidden;
}
.user-controls {
float: right;
}
.logged-in-user{
float: right;
margin-left: 140px;
}
.logged-in-user p {
margin: 0;
}
/* Form Elements */
fieldset {
border: 0;
padding: 0;
}
.form-el {
margin: 10px 0;
}
.btn {
display: inline-block;
padding: 4px 12px;
margin-bottom: 0;
font-size: 14px;
line-height: 20px;
color: #333333;
text-align: center;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
vertical-align: middle;
cursor: pointer;
background-color: #f5f5f5;
background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
background-repeat: repeat-x;
border: 1px solid #cccccc;
border-color: #e6e6e6 #e6e6e6 #bfbfbf;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
border-bottom-color: #b3b3b3;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
input[type="text"],
input[type="number"],
input[type="password"],
textarea {
background-color: #fff;
border: 1px solid #ccc;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-webkit-transition: border linear .2s,box-shadow linear .2s;
-moz-transition: border linear .2s,box-shadow linear .2s;
-o-transition: border linear .2s,box-shadow linear .2s;
transition: border linear .2s,box-shadow linear .2s;
padding: 8px 4px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
width: 270px;
font-size: 18px;
}
input[type="text"]:hover,
input[type="number"] :hover,
input[type="password"]:hover {
border-color: rgba(82, 168, 236, 0.8);
outline: 0;
outline: thin dotted 9;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
}
input[type="submit"] {
color: #ffffff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
background-color: #006dcc;
background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
background-image: linear-gradient(to bottom, #0088cc, #0044cc);
background-repeat: repeat-x;
border-color: #0044cc #0044cc #002a80;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
}
Now this is my login form that has the css on it
<html>
<head>
<meta charset="utf-8">
<title>Log-In</title>
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'/>
<link href="../css/core.css" rel="stylesheet" />
</head>
<body>
<div id="wrap">
<div id="head">
<h1>Login to the Assignment Upload System</h1>
</div>
<div class="content">
<form action="core/authenticate.php" method="POST">
<div class="form-wrap">
<fieldset>
<legend class="hidden">Login</legend>
<div class="form-el">
<label class="hidden" for="username">User name</label>
<input id="username" type="text" name="username" placeholder="Enter Your Username..."><br />
</div>
<div class="form-el">
<label class="hidden" for="password">Password</label>
<input id="password" type="password" name="password" placeholder="Enter Your Password..."><br />
Forgot Password?
</div>
<input class="btn" type="submit" value="Login">
</fieldset>
</div>
</form>
</div>
<?php if(isset($_GET["feedback"])){echo $_GET["feedback"];} ?>
</div>
</body>
</html>
Now i want my echo form in my php to look exactly like this page so how would i do this? because i am getting really confused with what people are saying
an easy way is to include bootstrap:
include this in the <head>
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" media="screen" />
then in all your inputs add class="form-control"
for example:
<input type="text" class="form-control" />
Just make sure you include your CSS file in the HTML file you are generating with your PHP Code.
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
give the form a class name like this:
echo "
<form action='pass_reset_complete.php?code=$get_code' method='POST' class='first_form'>
Enter A New Password...etc
then add style tag but out of the PHP codes:
<style>
.first_form{
background:#ccc;
width:300px;
border:solid #000 1px;
}
</style>
and you can styling input tags in the form like this:
<style>
.first_form{
background:#ccc;
width:300px;
border:solid #000 1px;
}
.first_form > input[type=password]{
width:250px;
color:#fff;
background:#333;
}
.first_form > input[type=submit]{
width:70px;
border:none;
}
</style>
Related
i got a "news" thing on my navigation bar, it uses marquee to have moving text but when the text gets too long, it pushes my content (not the content of the navigation bar but the main content on the website). it is also unable to start from the beginning of the navigation bar and rather chose to start from the middle but really depends on how long the text is...
navigationbar.php
<?php
function echoSelectedClassIfRequestMatches($requestUri)
{
$current_file_name = basename($_SERVER['REQUEST_URI']);
if ($current_file_name == $requestUri)
echo 'class="selected"';
}
?>
<!--START NAVIGATION-->
<div class="nav-align">
<div class="social-wrapper">
Social Media :
<i class="fa fa-facebook-official"></i><!--facebook-->
<i class="fa fa-twitter-square"></i><!--twitter-->
<i class="fa fa-youtube-play"></i><!--youtube-->
<i class="fa fa-google-plus-square"></i><!--google+-->
<i class="fa fa-instagram"></i><!--instagram-->
<i class="fa fa-steam-square"></i><!--steam-->
</div>
<nav class="nav-main">
<a href="/">
<img class="logo" src=""></img>
</a>
<?php
if(empty($_SESSION['user'])){
echo'<div class="user-container">';
echo'You are signed in as guest, please';
echo'Sign In';
echo'or';
echo'Sign Up';
echo'</div>';
}else {
echo'<div class="user-container">';
echo"<span><i class='fa fa-wrench'></i></span> <a class='a' href='/settings'> Settings";
echo"</a>";
echo" | ";
echo'<a class="a" href="/user/';
echo htmlentities($_SESSION['user']['id'], ENT_QUOTES, 'UTF-8');
echo '">';
echo htmlentities($_SESSION['user']['username'], ENT_QUOTES, 'UTF-8');
echo'</a> <span><i class="fa fa-user"></i></span>
Sign Out <i class="fa fa-sign-out"></i>';
echo'</div>';
}
?>
</nav>
<div class="nav-item-container">
<ul>
<li>
<div <?=echoSelectedClassIfRequestMatches("")?>>Home </div>
</li>
<li>
<div <?=echoSelectedClassIfRequestMatches("about")?>>About </div>
</li>
<li>
<div <?=echoSelectedClassIfRequestMatches("contact")?>>Contact </div>
</li>
<li>
<div <?=echoSelectedClassIfRequestMatches("forum")?>>Forum </div>
</li>
<li>
<div <?=echoSelectedClassIfRequestMatches("upload")?>>Upload </div>
</li>
<li>
<div <?=echoSelectedClassIfRequestMatches("server")?>>Server </div>
</li>
<li>
<div <?=echoSelectedClassIfRequestMatches("clan")?>>Clan </div>
</li>
<li>
<div <?=echoSelectedClassIfRequestMatches("misc")?>>Misc </div>
</li>
<div class="news-wrapper">
<div class="news-content">
<i class="fa fa-bullhorn"></i> NEWS :
</div>
</div>
</ul>
<ul>
<li style="overflow:hidden;">
<div class="marquee-wrapper">
<marquee behavior="scroll" direction="left" scrollamount="4" onmouseover="this.stop();" onmouseout="this.start();">
<?php
$items = Array(
"<span><i class='fa fa-bullhorn'></i> NEWS:</span> Welcome to the website!",
"Welcome <span> <a class='a2' href='/user/'>".htmlentities($row['username'], ENT_QUOTES, 'UTF-8')."</a></span> to the website!",
"We currently got <span> ".htmlentities($row['id'], ENT_QUOTES, 'UTF-8')." </span> Unique members :)",
//"You can easly visit other members profiles by typing '/user/[id]' just replace [id] by any number.",
);
echo $items[array_rand($items)];
?>
</marquee>
</div>
</li>
</ul>
</div>
</div>
nav-bar.css
#charset "utf-8";
.nav-align {
width:85.1%;
padding-top:40px;
margin:auto;
}
.nav-main{
margin:auto;
background-image: url("/images/background/navigationbar.jpg") !important;
border: 1px solid #000;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .2);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .2);
box-shadow: 0 1px 3px rgba(0, 0, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .2);
height:80px;
color:#858d9a;
z-index:50;
}
.nav-main .logo{
float:left;
color:#fff;
text-decoration: none;
width:20%;
padding:5px 20px;
font-size:1.4em;
line-height:30px;
}
.user-container {
float:right !important;
height:30px;
padding: 20px 20px;
font-size:15px;
}
.nav-item-container {
border-left:1px solid black;
border-right:1px solid black;
background-color: #1d1d1d;
background-image: -webkit-linear-gradient(bottom, #1a1b1f, #212528);
background-image: -moz-linear-gradient(bottom, #1a1b1f, #212528);
background-image: -o-linear-gradient(bottom, #1a1b1f, #212528);
background-image: linear-gradient(to top, #1a1b1f, #212528);
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .2);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .2);
box-shadow: 0 1px 3px rgba(0, 0, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .2);
height:30px;
}
.nav-item-container > ul{
float:left;
list-style-type:none;
overflow:hidden;
}
.nav-item-container > ul > li{
float:left;
}
.nav-item{
font-size:12px;
display:inline-block;
padding:5px 10px;
height:20px;
line-height:20px;
color:#7D91A3;
text-decoration:none;
}
.selected {
color:#05c7f7 !important;
}
.nav-item:hover {
color:#fff;
text-shadow: 0 1px 2px #000;
-webkit-box-shadow: 0 0 10px rgba(5,199,247,0.5), inset 0 0 1px 1px #05c7f7;
-moz-box-shadow: 0 0 10px rgba(5,199,247,0.5), inset 0 0 1px 1px #05c7f7;
box-shadow: 0 0 10px rgba(5,199,247,0.5), inset 0 0 1px 1px #05c7f7;
background-image: linear-gradient(to top, #096aa1, #26c3f6);
}
.nav-content{
position:absolute;
top:184px;
overflow:hidden;
background-color:#0d0f11;
max-height:0;
}
.nav-content a{
color:#fff;
text-decoration:none;
}
.nav-sub{
padding:10px;
}
.nav-sub ul{
padding:0;
margin:0;
list-style-type:none;
}
.nav-sub ul li a{
display:inline-block;
padding:3px 0;
padding-left:10px;
color:#7D91A3;
}
.nav-sub ul li a:hover{
color:#05c7f7;
}
.nav-item:focus ~ .nav-content{
max-height:100px;
border-left: 1px solid #000;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
background-color: #1d1d1d;
background-image: -webkit-linear-gradient(bottom, #1a1b1f, #212528);
background-image: -moz-linear-gradient(bottom, #1a1b1f, #212528);
background-image: -o-linear-gradient(bottom, #1a1b1f, #212528);
background-image: linear-gradient(to top, #1a1b1f, #212528);
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .2);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .2);
box-shadow: 0 1px 3px rgba(0, 0, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .2);
z-index:4000;
}
.social-wrapper {
border-top:1px solid black;
border-left:1px solid black;
border-right:1px solid black;
background-image: -webkit-linear-gradient(bottom, #1a1b1f, #212528);
background-image: -moz-linear-gradient(bottom, #1a1b1f, #212528);
background-image: -o-linear-gradient(bottom, #1a1b1f, #212528);
background-image: linear-gradient(to top, #1a1b1f, #212528);
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .2);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .2);
box-shadow: 0 1px 3px rgba(0, 0, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .2);
width:20%;
min-width:230px;
padding-left:10px;
padding-right:10px;
line-height:30px;
height:30px;
margin:auto;
}
.social-wrapper:hover {
color:#05c7f7;
}
.nav-social-icons {
padding-top:6px !important;
line-height:21.5px;
font-size:17px;
padding:3px;
color:#777f8c;
float:right;
}
.nav-social-icons:hover {
color:#fff;
-webkit-box-shadow: 0 0 10px rgba(5,199,247,0.5), inset 0 0 1px 1px #05c7f7;
-moz-box-shadow: 0 0 10px rgba(5,199,247,0.5), inset 0 0 1px 1px #05c7f7;
box-shadow: 0 0 10px rgba(5,199,247,0.5), inset 0 0 1px 1px #05c7f7;
background-image: linear-gradient(to top, #096aa1, #26c3f6);
}
.news-content {
background-color:#05c7f7;
color:#05c7f7;
padding:3px;
width:100%;
float:right;
font-weight:bold;
line-height:25px;
background-color: #1d1d1d;
-webkit-box-shadow: inset 0 1px 1px rgba(255, 255, 255, .2);
-moz-box-shadow: inset 0 1px 1px rgba(255, 255, 255, .2);
box-shadow: inset 0 1px 1px rgba(255, 255, 255, .2);
border: 1px solid #000;
background-image: -webkit-linear-gradient(bottom, #1a1b1f, #212528);
background-image: -moz-linear-gradient(bottom, #1a1b1f, #212528);
background-image: -o-linear-gradient(bottom, #1a1b1f, #212528);
background-image: linear-gradient(to top, #1a1b1f, #212528);
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-ms-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
}
.news-content:before {
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
}
.marquee-wrapper {
line-height:30px !important;
float:right;
}
.news-wrapper {
padding-left:120px !important;
float:right;
line-height:25px;
}
a wrapper above all content
.content-wrapper { background-image: url("/images/background/content.jpg") !important; width:85%; border: 1px solid #000; background-image: -webkit-linear-gradient(bottom, #1a1b1f, #212528); background-image: -moz-linear-gradient(bottom, #1a1b1f, #212528); background-image: -o-linear-gradient(bottom, #1a1b1f, #212528); background-image: linear-gradient(to top, #1a1b1f, #212528); margin:auto;}
Do not use the <marquee> element, it is deprecated.
“This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.”
https://developer.mozilla.org/en/docs/Web/HTML/Element/marquee
But to fix your problem you could try adding overflow: hidden to either .marquee-wrapper or .marquee-wrapper marquee
I am trying to create a login and registration form..when I created them without any styling it worked perfectly..later I enhanced those pages by adding responsive css and html styling..In this design when the user enters the site he'll see something like the login and registration are side by side one is login link and other is register link.when clicked on login link the background changes to white and link is activated..same for other..i used the concept of radio buttons for this..
In this design Iam facing 2 problems..
1)when i click on the green background of register link the colour
jus shifts but the link is not responding..In order for it to
respond i have to click the text(register)..I want the link to work
jus by clicking the background..I knw I can simply use buttons but
Iam wondering of there's some other solution...
the registration and login form wont even respond ..they just stay idle when i enter the data..initially it worked..but after including this login template with it..it stopped responding..I tried to find out error but i couldnt
please someone help me solving these problems..
Here's the code for everything
login.php
<html>
<head>
<title>Login Form</title>
<style>
a:link {
color: black;
}
a:visited {
color: black;
}</style>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<?php
if (!isset($_POST['submit'])){
?>
<h1 class="register-title">Welcome</h1>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" class="register">
<div class="register-switch">
<input type="radio" name="type" value="L" id="login" class="register-switch-input" checked>
<label for="login" class="register-switch-label">Login</label>
<input type="radio" name="type" value="R" id="Register" class="register-switch-input">
<label for="Register" class="register-switch-label">Register</label>
</div>
<input type="text" name="username" class="register-input" placeholder="User Name">
<input type="password" name="password"class="register-input" placeholder="Password">
<input type="submit" name="submit" value="Login" class="register-button">
</form>
<?php
} else {
require_once("db_const.php");
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
# check connection
if ($mysqli->connect_errno) {
echo "<p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>";
exit();
}
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * from users WHERE username LIKE '{$username}' AND password LIKE '{$password}' LIMIT 1";
$result = $mysqli->query($sql);
if (!$result->num_rows == 1) {
echo "<p>Invalid username/password combination</p>";
} else {
echo "<p>Logged in successfully</p>";
// do stuffs
}
}
?>
</body>
</html>
register.php
<!DOCTYPE html>
<head>
<title>Registration Form</title>
<link rel="stylesheet" href="css/style.css">
<style>
a:link {
color: black;
}
a:visited {
color: black;
}</style>
</head>
<body>
<?php
require_once("db_const.php");
if (!isset($_POST['submit'])) {
?>
<h1 class="register-title">Welcome</h1>
<form class="register">
<div class="register-switch">
<input type="radio" name="type" value="L" id="login" class="register-switch-input">
<label for="login" class="register-switch-label">Login</label>
<input type="radio" name="type" value="R" id="Register" class="register-switch-input" checked>
<label for="Register" class="register-switch-label">Register</label>
</div>
<input type="text" name="username" class="register-input" placeholder="User Name">
<input type="password" name="password" class="register-input" placeholder="Password">
<input type="text" name="first_name" class="register-input" placeholder="First Name">
<input type="text" name="last_name" class="register-input" placeholder="Last Name">
<input type="email" name="email" class="register-input" placeholder="Email Address">
<input type="submit" name="submit" value="Register" class="register-button">
</form>
<?php
} else {
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
# check connection
if ($mysqli->connect_errno) {
echo "<p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>";
exit();
}
# prepare data for insertion
$username = $_POST['username'];
$password = $_POST['password'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
# check if username and email exist else insert
$exists = 0;
$result = $mysqli->query("SELECT username from users WHERE username = '{$username}' LIMIT 1");
if ($result->num_rows == 1) {
$exists = 1;
$result = $mysqli->query("SELECT email from users WHERE email = '{$email}' LIMIT 1");
if ($result->num_rows == 1) $exists = 2;
} else {
$result = $mysqli->query("SELECT email from users WHERE email = '{$email}' LIMIT 1");
if ($result->num_rows == 1) $exists = 3;
}
if ($exists == 1) echo "<p>Username already exists!</p>";
else if ($exists == 2) echo "<p>Username and Email already exists!</p>";
else if ($exists == 3) echo "<p>Email already exists!</p>";
else {
$sql = "INSERT INTO `users` (`id`, `username`, `password`, `first_name`, `last_name`, `email`)
VALUES (NULL, '{$username}', '{$password}', '{$first_name}', '{$last_name}', '{$email}')";
if ($mysqli->query($sql)) {
//echo "New Record has id ".$mysqli->insert_id;
echo "<p>Registered successfully!</p>";
} else {
echo "<p>MySQL error no {$mysqli->errno} : {$mysqli->error}</p>";
exit();
}
}
}
?>
</body>
</html>
db_const.php
<?php
# mysql db constants DB_HOST, DB_USER, DB_PASS, DB_NAME
const DB_HOST = 'localhost';
const DB_USER = 'root';
const DB_PASS = '';
const DB_NAME = 'php_mysql_login_system';
?>
style.css
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
body {
font: 14px/20px 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: #404040;
background: #2d4259;
}
.register-title {
width: 270px;
line-height: 43px;
margin: 50px auto 20px;
font-size: 19px;
font-weight: 500;
color: white;
color: rgba(255, 255, 255, 0.95);
text-align: center;
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
background: #d7604b;
border-radius: 3px;
background-image: -webkit-linear-gradient(top, #dc745e, #d45742);
background-image: -moz-linear-gradient(top, #dc745e, #d45742);
background-image: -o-linear-gradient(top, #dc745e, #d45742);
background-image: linear-gradient(to bottom, #dc745e, #d45742);
-webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3);
box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3);
}
.register {
margin: 0 auto;
width: 230px;
padding: 20px;
background: #f4f4f4;
border-radius: 3px;
-webkit-box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3);
box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3);
}
input {
font-family: inherit;
font-size: inherit;
color: inherit;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.register-input {
display: block;
width: 100%;
height: 38px;
margin-top: 2px;
font-weight: 500;
background: none;
border: 0;
border-bottom: 1px solid #d8d8d8;
}
.register-input:focus {
border-color: #1e9ce6;
outline: 0;
}
.register-button {
display: block;
width: 100%;
height: 42px;
margin-top: 25px;
font-size: 16px;
font-weight: bold;
color: #494d59;
text-align: center;
text-shadow: 0 1px rgba(255, 255, 255, 0.5);
background: #fcfcfc;
border: 1px solid;
border-color: #d8d8d8 #d1d1d1 #c3c3c3;
border-radius: 2px;
cursor: pointer;
background-image: -webkit-linear-gradient(top, #fefefe, #eeeeee);
background-image: -moz-linear-gradient(top, #fefefe, #eeeeee);
background-image: -o-linear-gradient(top, #fefefe, #eeeeee);
background-image: linear-gradient(to bottom, #fefefe, #eeeeee);
-webkit-box-shadow: inset 0 -1px rgba(0, 0, 0, 0.03), 0 1px rgba(0, 0, 0, 0.04);
box-shadow: inset 0 -1px rgba(0, 0, 0, 0.03), 0 1px rgba(0, 0, 0, 0.04);
}
.register-button:active {
background: #eee;
border-color: #c3c3c3 #d1d1d1 #d8d8d8;
background-image: -webkit-linear-gradient(top, #eeeeee, #fcfcfc);
background-image: -moz-linear-gradient(top, #eeeeee, #fcfcfc);
background-image: -o-linear-gradient(top, #eeeeee, #fcfcfc);
background-image: linear-gradient(to bottom, #eeeeee, #fcfcfc);
-webkit-box-shadow: inset 0 1px rgba(0, 0, 0, 0.03);
box-shadow: inset 0 1px rgba(0, 0, 0, 0.03);
}
.register-button:focus {
outline: 0;
}
.register-switch {
height: 32px;
margin-bottom: 15px;
padding: 4px;
background: #6db244;
border-radius: 2px;
background-image: -webkit-linear-gradient(top, #60a83a, #7dbe52);
background-image: -moz-linear-gradient(top, #60a83a, #7dbe52);
background-image: -o-linear-gradient(top, #60a83a, #7dbe52);
background-image: linear-gradient(to bottom, #60a83a, #7dbe52);
-webkit-box-shadow: inset 0 1px rgba(0, 0, 0, 0.05), inset 1px 0 rgba(0, 0, 0, 0.02), inset -1px 0 rgba(0, 0, 0, 0.02);
box-shadow: inset 0 1px rgba(0, 0, 0, 0.05), inset 1px 0 rgba(0, 0, 0, 0.02), inset -1px 0 rgba(0, 0, 0, 0.02);
}
.register-switch-input {
display: none;
}
.register-switch-label {
float: left;
width: 50%;
line-height: 32px;
color: white;
text-align: center;
text-shadow: 0 -1px rgba(0, 0, 0, 0.2);
cursor: pointer;
}
.register-switch-input:checked + .register-switch-label {
font-weight: 500;
color: #434248;
text-shadow: 0 1px rgba(255, 255, 255, 0.5);
background: white;
border-radius: 2px;
background-image: -webkit-linear-gradient(top, #fefefe, #eeeeee);
background-image: -moz-linear-gradient(top, #fefefe, #eeeeee);
background-image: -o-linear-gradient(top, #fefefe, #eeeeee);
background-image: linear-gradient(to bottom, #fefefe, #eeeeee);
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.1);
}
:-moz-placeholder {
color: #aaa;
font-weight: 300;
}
::-moz-placeholder {
color: #aaa;
font-weight: 300;
opacity: 1;
}
::-webkit-input-placeholder {
color: #aaa;
font-weight: 300;
}
:-ms-input-placeholder {
color: #aaa;
font-weight: 300;
}
::-moz-focus-inner {
border: 0;
padding: 0;
}
probably, you should be facing problem with registration form, as the form tag is wrong
< form class="register" >
should be
< form method="post" action="" class="register" >
My divs keep shifting when I resize the page can someone help me with this?
html/php (php for login and page getter)
my html body part with some php for login in and something with the page
<div class="menu">
<img src="logo.png" style=" position: relative; margin-right: 38%">
<ul class="dropdown">
<li><a href="?page=Home" <?php if ($page == 'Home') { ?> id="a-active" <?php } ?> >Home</a>
<ul class="sub_menu">
<li>News</li>
<li>Servers</li>
</ul>
</li>
<li><a href="?page=Forum" <?php if ($page == 'Forum') { ?> id="a-active" <?php } ?> >Forum</a>
<ul class="sub_menu">
<li>Common</li>
<li>Information</li>
<li>Griefs & Player reports</li>
<li>
Unbans
</li>
</ul>
</li>
<li><a href="?page=Information" <?php if ($page == 'Information') { ?> id="a-active" <?php } ?> >Information</a>
<ul class="sub_menu">
<li>
Rules
</li>
<li>
Staff
</li>
<li>
Servers
<ul>
<li>Survival</li>
<li>Games</li>
</ul>
</li>
</ul>
</li>
<li><a href="?page=Topscores" <?php if ($page == 'Topscores') { ?> id="a-active" <?php } ?> > Topscores</a>
<ul class="sub_menu">
<li>Playtime</li>
<li>Kills</li>
<li>Game wins</li>
</ul>
</li>
<li><a href="?page=Donations" <?php if ($page == 'Donations') { ?> id="a-active" <?php } ?> >Donation</a>
</li>
</ul>
<div class="content">
<?php
if ($page == 'Forum') {
include 'forum/index.html';
} elseif ($page == 'Information') {
include 'information/index.html';
} elseif ($page == 'Topscores') {
include 'topscores/index.html';
} elseif ($page == 'Donations') {
include 'donations/index.html';
} elseif ($page == 'Home') {
include 'home/index.html';
} else {
include '404/index.html';
}
?>
</div>
<div class="contentmirror1">
<?php
if (isset($_SESSION['username'])) {
?>
<form width="110px" id="form1" name="form1" method="post" action="logout.php">
<table width="100px" border="0" align="center">
<tr>
<td colspan="2">Welcome</td>
</tr>
<tr>
<td><input readonly type="text" name="name" style="border:none; background-color: transparent;" value="<?php echo htmlspecialchars($_SESSION['username']); ?>"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="button" id="button" value="Logout" /></td>
</tr>
</table>
</form>
<?php
} else {
?>
<form width="110px" id="form1" name="form1" method="post" action="login.php">
<table width="100px" border="0" align="center">
<tr>
<td colspan="2">Login</td>
</tr>
<tr>
<td>Username:</td>
<td><input type="text" name="username" id="username" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" id="password" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="button" id="button" value="Login" /></td>
</tr>
</table>
</form>
<?php
}
?>
</div>
<div class="contentmirror" style="Clear: Both;">
spambox/online shizzle
</div>
</div>
my css
.head{
height: 115px;
width: 100%;
position: absolute;
top: 0px;
left: 0px;
background: rgb(200,200,200);
z-index: -999;
}
html {
background: url('background.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.menu{
display: inline-block;
position: absolute;
padding: 2%;
text-align: center;
width: 86%;
left: 0px;
top: 0px;
font-family: arial;
z-index: 0;
}
.menu::after {
padding-top: 56.25%; /* percentage of containing block _width_ */
display: block;
content: '';
}
.content{
float: left;
margin-top: 5%;
width: 60%;
max-width: 60%;
padding: 1%;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
}
.contentmirror{
float: right;
margin-top: -3%;
margin-right: 5%;
max-width: 26%;
width: 26%;
padding: 1%;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
}
.contentmirror1{
float: right;
margin-top: -25%;
margin-right: 8%;
max-width: 26%;
width: 26%;
padding: 1%;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
}
.sidepanelright{
float: right;
}
.main{
text-align: center;
font-family: arial;
font-size: 24px;
}
.pics {
width: 70%;
max-height: 100%;
margin: 0px auto;
}
.pic {
display: none;
background-color: transparent;
border: none;
width: 100%;
max-height: 100%;
}
.menu a{
color: black;
background-color: white;
padding: 5px 10px;
margin: 0px 5px;
border-radius: 10px;
text-decoration: none;
-moz-box-shadow: 0px 0px 20px 0px #4E4E4E;
-webkit-box-shadow: 0px 0px 20px 0px #4E4E4E;
box-shadow: 0px 0px 20px 0px #4E4E4E;
z-index: 0;
}
.menu a:hover{
padding: 7px 12px;
-moz-box-shadow: 0px 0px 30px 0px white;
-webkit-box-shadow: 0px 0px 30px 0px white;
box-shadow: 0px 0px 30px 0px white;
}
#logo{
float: left;
top: -90px;
position: relative;
margin: 5px 0px 0px 5px;
width: 15%;
max-height: 100%;
z-index: 1;
}
.btn:hover, .btn:focus {
color: #333333;
text-decoration: none;
background-position: 0 -15px;
-webkit-transition: background-position 0.1s linear;
-moz-transition: background-position 0.1s linear;
-o-transition: background-position 0.1s linear;
transition: background-position 0.1s linear;
}
.btn:hover, .btn:focus, .btn:active, .btn.active, .btn.disabled, .btn[disabled] {
color: #333333;
background-color: #e6e6e6;
}
.btn {
display: inline-block;
padding: 4px 12px;
margin-bottom: 0;
font-size: 14px;
line-height: 20px;
color: #333333;
text-align: center;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
vertical-align: middle;
cursor: pointer;
background-color: #f5f5f5;
background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
background-repeat: repeat-x;
border: 1px solid #cccccc;
border-color: #e6e6e6 #e6e6e6 #bfbfbf;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
border-bottom-color: #b3b3b3;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
#btn {
display: inline-block;
padding: 4px 12px;
margin-bottom: 0;
font-size: 14px;
line-height: 20px;
color: #333333;
text-align: center;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
vertical-align: middle;
cursor: pointer;
background-color: #f5f5f5;
background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
background-repeat: repeat-x;
border: 1px solid #cccccc;
border-color: #e6e6e6 #e6e6e6 #bfbfbf;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
border-bottom-color: #b3b3b3;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
#btn:hover, #btn:focus, #btn:active, #btn.active, #btn.disabled, #btn[disabled] {
color: #333333;
background-color: #e6e6e6;
}
#btn:hover, #btn:focus {
color: #333333;
text-decoration: none;
background-position: 0 -15px;
-webkit-transition: background-position 0.1s linear;
-moz-transition: background-position 0.1s linear;
-o-transition: background-position 0.1s linear;
transition: background-position 0.1s linear;
}
#a-active{
color: black;
background-color: #DDDDDD;
padding: 5px 10px;
margin: 0px 5px;
border-radius: 10px;
text-decoration: none;
-moz-box-shadow: 0px 0px 20px 0px #4E4E4E;
-webkit-box-shadow: 0px 0px 20px 0px #4E4E4E;
box-shadow: 0px 0px 20px 0px #4E4E4E;
z-index: 0;
}
#a-active:hover{
background-color: white;
padding: 7px 12px;
-moz-box-shadow: 0px 0px 30px 0px white;
-webkit-box-shadow: 0px 0px 30px 0px white;
box-shadow: 0px 0px 30px 0px white;
}
* { margin: 0; padding: 0; }
body { font: 14px Helvetica, Sans-Serif; }
#page-wrap { width: 800px; margin: 25px auto; }
a { text-decoration: none; }
ul { list-style: none;}
p { margin: 15px 0; }
/*
LEVEL ONE
*/
.drops{
margin-left: 30%;
}
ul.dropdown { position: relative; margin-left: 37%; margin-top: 2%;}
ul.dropdown li { font-weight: bold; float: left; zoom: 1; }
ul.dropdown a:hover { }
ul.dropdown a:active { }
ul.dropdown li a { display: block; padding: 4px 8px; border-right: 1px solid #333;
}
ul.dropdown li:last-child a { border-right: none; } /* Doesn't work in IE */
ul.dropdown li.hover,
ul.dropdown li:hover { color: black; position: relative; }
ul.dropdown li.hover a { color: black; }
/*
LEVEL TWO
*/
ul.dropdown ul { width: 220px; visibility: hidden; position: absolute; top: 100%; left: 0; }
ul.dropdown ul li { font-weight: normal; float: none; }
/* IE 6 & 7 Needs Inline Block */
ul.dropdown ul li a { border-right: none; width: 100%; display: inline-block; }
/*
LEVEL THREE
*/
ul.dropdown ul ul { left: 100%; top: 0; }
ul.dropdown li:hover > ul { visibility: visible; }
when I resize the window the divs shifts to the left or down. is there a way to set those divs on one position where they do not shift positions just stay there?
I pretty much didn't understand your code, but made this fiddle to make you understand how to fix the divs.
I would suggest you to avoid float for divs and do something like:
.fix{
/* this is parent div */
display:inline-block ;
white-space:nowrap;
}
.fxchld{
/* these are child divs */
width:50px;
display:inline-block ;
height:50px;
border:1px solid #000;
}
idea is to use display:inline-block ; instead of floats so that they remain fixed to their position
else
you'll have to give large parent div width so that child divs won't wrap
Fiddle will help you understand my point!!
My webpage that I am working on works fine in other browsers except IE. I am using IE 10 (the preview version) so I can use shadows, and the <br /> isn't working so I made an IE-specific css so that if the browser is IE, it loads the IE css. Well, when I go to change the margins for the .homepagetable, it also applies the css to the other browsers. The difference between main.css and all-ie-only.css is the .homepagetable.
Index.php
<? include("inc/incfiles/header.inc.php"); ?>
<?
$reg = #$_POST['reg'];
//declaring variables to prevent errors
$fn = ""; //First Name
$ln = ""; //Last Name
$un = ""; //Username
$em = ""; //Email
$em2 = ""; //Email 2
$pswd = ""; //Password
$pswd2 = ""; //Password 2
$d = ""; //Sign up Date
$u_check = ""; //Check if username exists
//registration form
$fn = strip_tags(#$_POST['fname']);
$ln = strip_tags(#$_POST['lname']);
$un = strip_tags(#$_POST['username']);
$em = strip_tags(#$_POST['email']);
$em2 = strip_tags(#$_POST['email2']);
$pswd = strip_tags(#$_POST['password']);
$pswd2 = strip_tags(#$_POST['password2']);
$d = date("y-m-d"); // Year - Month - Day
if ($reg) {
if ($em==$em2) {
// Check if user already exists
$u_check = mysql_query("SELECT username FROM users WHERE username='$un'");
// Count the amount of rows where username = $un
$check = mysql_num_rows($u_check);
if ($check == 0) {
//check all of the fields have been filled in
if ($fn&&$ln&&$un&&$em&&$em2&&$pswd&&$pswd2) {
// check that passwords match
if ($pswd==$pswd2) {
// check the maximum length of username/first name/last name does not exceed 25 characters
if (strlen($un)>25||strlen($fn)>25||strlen($ln)>25) {
echo "The maximum limit for username/first name/last name is 25 characters!";
}
else
{
// check the length of the password is between 5 and 30 characters long
if (strlen($pswd)>30||strlen($pswd)<5) {
echo "Your password must be between 5 and 30 characters long!";
}
else
{
//encrypt password and password 2 using md5 before sending to database
$pswd = md5($pswd);
$pswd2 = md5($pswd2);
$query = mysql_query("INSERT INTO users VALUES ('','$un','$fn','$ln','$em','$pswd','d','0')");
die("<h2>Welcome to Rebel Connect</h2>Login to your account to get started.");
}
}
}
else {
echo "Your passwords don't match!";
}
}
else
{
echo "Please fill in all fields";
}
}
else
{
echo "Username already taken.";
}
}
else {
echo "Your e-mails don't match!";
}
}
?>
<?
//Login Script
if (isset($_POST["user_login"]) && isset($_POST["password_login"])) {
$user_login = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["user_login"]); // filter everything but numbers and letters
$password_login = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password_login"]); // filter everything but numbers and letters
$password_login=md5($password_login);
$sql = mysql_query("SELECT id FROM users WHERE username='$user_login' AND password='$password_login' LIMIT 1"); // query the person
//Check for their existance
$userCount = mysql_num_rows($sql); //Count the number of rows returned
if ($userCount == 1) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
}
$_SESSION["id"] = $id;
$_SESSION["user_login"] = $user_login;
$_Session["password_login"] = $password_login;
exit("<meta http-equiv=\"refresh\" content=\"0\">");
} else {
echo 'That information is incorrect, try again';
exit();
}
}
?>
<table class="homepageTable">
<tr>
<td width="60%" valign="top">
<h2>Already a member? Login below.</h2>
<form action="index.php" method="post" name="form1" id="form1">
<input type="text" size="25" name="user_login" id="user_login" placeholder="username" />
<br />
<input type="password" size="25" name="password_login" id="password_login" placeholder="password" />
<br />
<input type="submit" name="button" id="button" value="Login to your account!">
</form>
</td>
<td width="40%" valign="top">
<h2>Sign up below...</h2>
<form action="#" method="post">
<input type="text" size="25" name="fname" placeholder="First Name" value="<? echo $fn; ?>">
<input type="text" size="25" name="lname" placeholder="Last Name" value="<? echo $ln; ?>">
<input type="text" size="25" name="username" placeholder="Username" value="<? echo $un; ?>">
<input type="text" size="25" name="email" placeholder="Email" value="<? echo $em; ?>">
<input type="text" size="25" name="email2" placeholder="Re-enter Email" value="<? echo $em2; ?>">
<input type="password" size="25" name="password" placeholder="password" value="<? echo $pswd; ?>">
<input type="password" size="25" name="password2" placeholder="Re-enter Password" value="<? echo $pswd2; ?>"><br />
<input type="submit" name="reg" value="Sign Up!">
</form>
</td>
</tr>
</table>
</body>
</html>
header.inc.php
<?
include ("inc/scripts/mysql_connect.inc.php");
session_start();
if (!isset($_SESSION["user_login"])) {
}
else
{
header("location: home.php");
}
?>
<html>
<head>
<if !IE>
<link href="css/main.css" rel="stylesheet" type="text/css">
<if IE>
<link rel="stylesheet" type="text/css" href="css/all-ie-only.css" />
<title>Rebel Reach - PHS Student Social Network</title>
</head>
<body>
<div class="headerMenu">
<div id="wrapper">
<div class="logo">
<img src="img/find_friends_logo.png">
</div>
<div class="search_box">
<form method="get" action="search.php" id="search">
<input name="q" type="text" size="60" placeholder="Search..." />
</form>
</div>
<div id="menu">
Home
About
Sign Up
Login
</div>
</div>
</div>
<br />
<br />
<br />
<br />
main.css
* {
margin: 0px;
padding: 0px;
font-family: Arial;
font-size: 12px;
background-color: #eff5f9
}
.headerMenu {
background-image:url(../img/menu_bg.png);
height: 56px;
border-bottom: 0px;
width: 100%;
position:fixed;
}
#wrapper {
margin-left: auto;
margin-right: auto;
width: 1000px;
padding-top: 0px;
padding-bottom: 0px;
background-image:url(../img/menu_bg.png);
}
.logo {
margin-left: 0px;
width: 125px;
}
.logo img {
padding-top: 7px;
width: 150px;
height: 38px;
background-image:url(../img/menu_bg.png);
}
.search_box {
background-image: url(../img/menu_bg.png);
position: absolute;
top: 13px;
margin-left: 150px;
border:inset 2px
}
#search input[type="text"] {
background: url(../img/search-white.png) no-repeat 10px 6px #666;
outline: none;
border: 0 none;
font: bold 12px Arial,Helvetica,Sans-serif;
width: 350px;
padding: 6px 15px 6px 35px;
text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
-webkit-transition: all 0.7s ease 0s;
-moz-transition: all 0.7s ease 0s;
-o-transition: all 0.7s ease 0s;
transition: all 0.7s ease 0s;
margin-bottom: 0px;
margin-top: 0px;
}
#search input[type="text"]:focus {
background: url(../img/search-dark.png) no-repeat 10px 6px #fcfcfc;
color: #6a6f75;
width: 350px;
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
text-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
}
#media screen and (max-width:1280px) {
#menu {
background-image:url(../img/menu_bg.png);
position:absolute; top:0px; right:0px;
height: 37px;
padding-top: 16px;
margin-right: 4%;
}
}
#media screen and (min-width:1280px) {
#menu {
background-image:url(../img/menu_bg.png);
position:absolute; top:0px; right:0px;
height: 37px;
padding-top: 16px;
margin-right: 6%;
}
}
#media screen and (min-width:1400px) {
#menu {
background-image:url(../img/menu_bg.png);
position:absolute; top:0px; right:0px;
height: 37px;
padding-top: 19px;
margin-right: 10%;
}
}
#media screen and (min-width:1920px) {
#menu {
background-image:url(../img/menu_bg.png);
position:absolute; top:0px; right:0px;
height: 37px;
padding-top: 19px;
margin-right: 25%;
}
}
#menu a {
color: #ffffff;
text-decoration: none;
font-size: 14px;
background-image:url(../img/menu_bg.png);
background-repeat: no-repeat;
padding-top: 16px;
padding-bottom: 22px;
padding-left: 10px;
padding-right: 10px;
}
#menu a:hover {
color: #ffffff;
text-decoration: none;
font-size: 14px;
background-image:url(../img/menu_bg_hover_mouse_over.png);
background-repeat: no-repeat;
padding-top: 16px;
padding-bottom: 22px;
padding-left: 10px;
padding-right: 10px;
}
h2 {
font-family: Arial;
font-size: 18px;
padding: 5px;
color: #0084C6;
}
input[type="text"] {
background-color: #FFFFFF;
border: 1px solid #E2E2E2;
font-size: 15px;
padding: 5px;
width: 300px;
margin-bottom: 3px;
margin-top: 3px;
outline:none;
}
input[type="text"]:hover {
border: 1px solid #0084C6;
}
input[type="password"] {
background-color: #FFFFFF;
border: 1px solid #E2E2E2;
font-size: 15px;
padding: 5px;
width: 300px;
margin-bottom: 3px;
margin-top: 3px;
outline:none;
}
input[type="password"]:hover {
border: 1px solid #0084C6;
}
input[type="submit"] {
background-color: #006fc4;
border: 1px solid #00508d;
font-size: 15px;
color: #FFFFFF;
padding: 5px;
margin-bottom: 3px;
margin-top: 3px;
border-radius: 7px;
}
.homepageTable {
padding: 10px;
}
all-ie-only.css
* {
margin: 0px;
padding: 0px;
font-family: Arial;
font-size: 12px;
background-color: #eff5f9
}
.headerMenu {
background-image:url(../img/menu_bg.png);
height: 56px;
border-bottom: 0px;
width: 100%;
position:fixed;
}
#wrapper {
margin-left: auto;
margin-right: auto;
width: 1000px;
padding-top: 0px;
padding-bottom: 0px;
background-image:url(../img/menu_bg.png);
}
.logo {
margin-left: 0px;
width: 125px;
}
.logo img {
padding-top: 7px;
width: 150px;
height: 38px;
background-image:url(../img/menu_bg.png);
}
.search_box {
background-image: url(../img/menu_bg.png);
position: absolute;
top: 13px;
margin-left: 150px;
border:inset 2px
}
#search input[type="text"] {
background: url(../img/search-white.png) no-repeat 10px 6px #666;
outline: none;
border: 0 none;
font: bold 12px Arial,Helvetica,Sans-serif;
width: 350px;
padding: 6px 15px 6px 35px;
text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
-webkit-transition: all 0.7s ease 0s;
-moz-transition: all 0.7s ease 0s;
-o-transition: all 0.7s ease 0s;
transition: all 0.7s ease 0s;
margin-bottom: 0px;
margin-top: 0px;
}
#search input[type="text"]:focus {
background: url(../img/search-dark.png) no-repeat 10px 6px #fcfcfc;
color: #6a6f75;
width: 350px;
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
}
#media screen and (max-width:1280px) {
#menu {
background-image:url(../img/menu_bg.png);
position:absolute; top:0px; right:0px;
height: 37px;
padding-top: 16px;
margin-right: 4%;
}
}
#media screen and (min-width:1280px) {
#menu {
background-image:url(../img/menu_bg.png);
position:absolute; top:0px; right:0px;
height: 37px;
padding-top: 16px;
margin-right: 6%;
}
}
#media screen and (min-width:1400px) {
#menu {
background-image:url(../img/menu_bg.png);
position:absolute; top:0px; right:0px;
height: 37px;
padding-top: 19px;
margin-right: 10%;
}
}
#media screen and (min-width:1920px) {
#menu {
background-image:url(../img/menu_bg.png);
position:absolute; top:0px; right:0px;
height: 37px;
padding-top: 19px;
margin-right: 25%;
}
}
#menu a {
color: #ffffff;
text-decoration: none;
font-size: 14px;
background-image:url(../img/menu_bg.png);
background-repeat: no-repeat;
padding-top: 16px;
padding-bottom: 22px;
padding-left: 10px;
padding-right: 10px;
}
#menu a:hover {
color: #ffffff;
text-decoration: none;
font-size: 14px;
background-image:url(../img/menu_bg_hover_mouse_over.png);
background-repeat: no-repeat;
padding-top: 16px;
padding-bottom: 22px;
padding-left: 10px;
padding-right: 10px;
}
h2 {
font-family: Arial;
font-size: 18px;
padding: 5px;
color: #0084C6;
clear: both;
}
input[type="text"] {
background-color: #FFFFFF;
border: 1px solid #E2E2E2;
font-size: 15px;
padding: 5px;
width: 300px;
margin-bottom: 3px;
margin-top: 3px;
outline:none;
}
input[type="text"]:hover {
border: 1px solid #0084C6;
}
input[type="password"] {
background-color: #FFFFFF;
border: 1px solid #E2E2E2;
font-size: 15px;
padding: 5px;
width: 300px;
margin-bottom: 3px;
margin-top: 3px;
outline:none;
}
input[type="password"]:hover {
border: 1px solid #0084C6;
}
input[type="submit"] {
background-color: #006fc4;
border: 1px solid #00508d;
font-size: 15px;
color: #FFFFFF;
padding: 5px;
margin-bottom: 3px;
margin-top: 3px;
border-radius: 7px;
}
.homepageTable {
padding: 10px;
}
You should definitely listen to #SDC's comment regarding security flaws. That's a far more significant issue than cross-browser compatibility.
Aside from that, your code isn't working because this:
<if !IE>
<link href="css/main.css" rel="stylesheet" type="text/css">
<if IE>
<link rel="stylesheet" type="text/css" href="css/all-ie-only.css" />
isn't valid.
IE10 should be compliant with the same standards as other browsers. It sounds like IE10 is running in quirks mode at the moment. Dropping a <!DOCTYPE> in immediately before your <html> should fix the problem. Then, you don't need to use your conditionals.
If you're still stuck on the idea of using conditionals, try something like:
<link href="css/main.css" rel="stylesheet" type="text/css">
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/all-ie-only.css" />
<![endif]-->
But, this includes both main.css and all-ie-only.css.
I am facing troubles with sessions codes
here is login code:
<?php
/**
* #author Mina Wilson
* #copyright 2012
* // EPCI Pharma Survey | Rights Reserved
*/
// Inialize session
session_start();
// Check, if user is already login, then jump to secured page
if (isset($_SESSION['name'])) {
header('Location: login_process.php');
}
?>
<?php $login="login_process.php" ?>
<!DOCTYPE html>
<html>
<head>
<title>EPCI Pharma Survey</title>
<style>
html, body
{
height: 100%;
}
body
{
font: 12px 'Lucida Sans Unicode', 'Trebuchet MS', Arial, Helvetica;
margin: 0;
background-color: #d9dee2;
background-image: -webkit-gradient(linear, left top, left bottom, from(#ebeef2), to(#d9dee2));
background-image: -webkit-linear-gradient(top, #ebeef2, #d9dee2);
background-image: -moz-linear-gradient(top, #ebeef2, #d9dee2);
background-image: -ms-linear-gradient(top, #ebeef2, #d9dee2);
background-image: -o-linear-gradient(top, #ebeef2, #d9dee2);
background-image: linear-gradient(top, #ebeef2, #d9dee2);
}
/*--------------------*/
#login
{
background-color: #fff;
background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#eee));
background-image: -webkit-linear-gradient(top, #fff, #eee);
background-image: -moz-linear-gradient(top, #fff, #eee);
background-image: -ms-linear-gradient(top, #fff, #eee);
background-image: -o-linear-gradient(top, #fff, #eee);
background-image: linear-gradient(top, #fff, #eee);
height: 240px;
width: 400px;
margin: -150px 0 0 -230px;
padding: 30px;
position: absolute;
top: 50%;
left: 50%;
z-index: 0;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow:
0 0 2px rgba(0, 0, 0, 0.2),
0 1px 1px rgba(0, 0, 0, .2),
0 3px 0 #fff,
0 4px 0 rgba(0, 0, 0, .2),
0 6px 0 #fff,
0 7px 0 rgba(0, 0, 0, .2);
-moz-box-shadow:
0 0 2px rgba(0, 0, 0, 0.2),
1px 1px 0 rgba(0, 0, 0, .1),
3px 3px 0 rgba(255, 255, 255, 1),
4px 4px 0 rgba(0, 0, 0, .1),
6px 6px 0 rgba(255, 255, 255, 1),
7px 7px 0 rgba(0, 0, 0, .1);
box-shadow:
0 0 2px rgba(0, 0, 0, 0.2),
0 1px 1px rgba(0, 0, 0, .2),
0 3px 0 #fff,
0 4px 0 rgba(0, 0, 0, .2),
0 6px 0 #fff,
0 7px 0 rgba(0, 0, 0, .2);
}
#login:before
{
content: '';
position: absolute;
z-index: -1;
border: 1px dashed #ccc;
top: 5px;
bottom: 5px;
left: 5px;
right: 5px;
-moz-box-shadow: 0 0 0 1px #fff;
-webkit-box-shadow: 0 0 0 1px #fff;
box-shadow: 0 0 0 1px #fff;
}
/*--------------------*/
h1
{
text-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0px 2px 0 rgba(0, 0, 0, .5);
text-transform: uppercase;
text-align: center;
color: #666;
margin: 0 0 30px 0;
letter-spacing: 4px;
font: normal 26px/1 Verdana, Helvetica;
position: relative;
}
h1:after, h1:before
{
background-color: #777;
content: "";
height: 1px;
position: absolute;
top: 15px;
width: 120px;
}
h1:after
{
background-image: -webkit-gradient(linear, left top, right top, from(#777), to(#fff));
background-image: -webkit-linear-gradient(left, #777, #fff);
background-image: -moz-linear-gradient(left, #777, #fff);
background-image: -ms-linear-gradient(left, #777, #fff);
background-image: -o-linear-gradient(left, #777, #fff);
background-image: linear-gradient(left, #777, #fff);
right: 0;
}
h1:before
{
background-image: -webkit-gradient(linear, right top, left top, from(#777), to(#fff));
background-image: -webkit-linear-gradient(right, #777, #fff);
background-image: -moz-linear-gradient(right, #777, #fff);
background-image: -ms-linear-gradient(right, #777, #fff);
background-image: -o-linear-gradient(right, #777, #fff);
background-image: linear-gradient(right, #777, #fff);
left: 0;
}
/*--------------------*/
fieldset
{
border: 0;
padding: 0;
margin: 0;
}
/*--------------------*/
#inputs input
{
background: #f1f1f1 url(http://www.red-team-design.com/wp-content/uploads/2011/09/login-sprite.png) no-repeat;
padding: 15px 15px 15px 30px;
margin: 0 0 10px 0;
width: 353px; /* 353 + 2 + 45 = 400 */
border: 1px solid #ccc;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0 1px 1px #ccc inset, 0 1px 0 #fff;
-webkit-box-shadow: 0 1px 1px #ccc inset, 0 1px 0 #fff;
box-shadow: 0 1px 1px #ccc inset, 0 1px 0 #fff;
}
#username
{
background-position: 5px -2px !important;
}
#password
{
background-position: 5px -52px !important;
}
#inputs input:focus
{
background-color: #fff;
border-color: #e8c291;
outline: none;
-moz-box-shadow: 0 0 0 1px #e8c291 inset;
-webkit-box-shadow: 0 0 0 1px #e8c291 inset;
box-shadow: 0 0 0 1px #e8c291 inset;
}
/*--------------------*/
#actions
{
margin: 25px 0 0 0;
}
#submit
{
background-color: #ffb94b;
background-image: -webkit-gradient(linear, left top, left bottom, from(#fddb6f), to(#ffb94b));
background-image: -webkit-linear-gradient(top, #fddb6f, #ffb94b);
background-image: -moz-linear-gradient(top, #fddb6f, #ffb94b);
background-image: -ms-linear-gradient(top, #fddb6f, #ffb94b);
background-image: -o-linear-gradient(top, #fddb6f, #ffb94b);
background-image: linear-gradient(top, #fddb6f, #ffb94b);
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
text-shadow: 0 1px 0 rgba(255,255,255,0.5);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
border-width: 1px;
border-style: solid;
border-color: #d69e31 #e3a037 #d5982d #e3a037;
float: left;
height: 35px;
padding: 0;
width: 120px;
cursor: pointer;
font: bold 15px Arial, Helvetica;
color: #8f5a0a;
}
#submit:hover,#submit:focus
{
background-color: #fddb6f;
background-image: -webkit-gradient(linear, left top, left bottom, from(#ffb94b), to(#fddb6f));
background-image: -webkit-linear-gradient(top, #ffb94b, #fddb6f);
background-image: -moz-linear-gradient(top, #ffb94b, #fddb6f);
background-image: -ms-linear-gradient(top, #ffb94b, #fddb6f);
background-image: -o-linear-gradient(top, #ffb94b, #fddb6f);
background-image: linear-gradient(top, #ffb94b, #fddb6f);
}
#submit:active
{
outline: none;
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
}
#submit::-moz-focus-inner
{
border: none;
}
#actions a
{
color: #3151A2;
float: right;
line-height: 35px;
margin-left: 10px;
}
/*--------------------*/
#back
{
display: block;
text-align: center;
position: relative;
top: 60px;
color: #999;
}
</style>
</head>
<body>
<form action="<?php echo $login; ?>" class="input" method="post" id="login">
<h1>EPCI Pharma Login</h1>
<fieldset id="inputs">
<input id="Name" name="name" type="text" placeholder="Name" autofocus required>
<input id="Password" name="password" type="password" placeholder="Password" required>
</fieldset>
<fieldset id="actions">
<input type="submit" id="submit" value="Log in">
Forgot your password?Register
</fieldset>
Back to article...
</form>
</body>
</html>
and here is login_process.php
<?php
session_start();
$host="localhost"; // Host name
$username="ebarea_epic"; // Mysql username
$password="..."; // Mysql password
$db_name="ebarea_epic"; // Database name
$tbl_name="medicalrep"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$name=$_POST['name'];
$password=$_POST['password'];
// To protect MySQL injection (more detail about MySQL injection)
$name = stripslashes($name);
$password = stripslashes($password);
$job_title= stripslashes ($job_title);
$name = mysql_real_escape_string($name);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM $tbl_name WHERE name='$name' and password='$password'";
$result=mysql_query($sql);
$num_results = mysql_num_rows($result);
$array = mysql_fetch_array($result);
$_SESSION['name']=$array['name'];
$_SESSION['password']=$array['password'];
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $username and $password, table row must be 1 row
if($count==1){
$_SESSION['name']=$_POST['name'];
$_SESSION['password']=$_POST['password'];
if ($array['job_title']=="user")
{ header ("location: userpage.php"); }
else if ($array['job_title']=="admin")
{ header ("location: adminpage.php"); }
}
else if ($name=="ahmedkamal8989#Epci" && $password=="epcisurvey2012#ahmed")
{ header ("location: adminpage.php"); }
else {
echo "Wrong user or password";
}
?>
if the user and password are wrong, it shows " Wrong user and password ", by refresh the login form again it redirects me to login_process.php with message " Wrong user or password "
I've tried to change the echo to header and the location of the login form, but it caused a redirect loop
Now what's the problem!
You should be redirecting after every form post.
In this case, in login_process.php, instead of echoing "Wrong password" you should be setting a session variable something like:
$_SESSION['message'] = "Wrong password";
Then redirect them back to the login page like this:
header("Location:/login.php", TRUE, 303);
On your login.php page, you should have something like this:
<?php echo $_SESSION['message']; unset($_SESSION['message']); ?>
Let me start with the important things in your PHP file
// username and password sent from form
$name=$_POST['name']; //Save the post in $name
$password=$_POST['password']; //Save the post in $password
$sql="SELECT * FROM $tbl_name WHERE name='$name' and password='$password'";
$result=mysql_query($sql);
$num_results = mysql_num_rows($result);
$array = mysql_fetch_array($result);
$_SESSION['name']=$array['name']; //OK you save the name in SESSION without knowing if the user has submitted the right login information
$_SESSION['password']=$array['password']; //OK you save the password in SESSION without knowing if the user has submitted the right login information
// Mysql_num_row is counting table row
$count=mysql_num_rows($result); //count always has to be 1 else failed login information
if($count==1){
$_SESSION['name']=$_POST['name']; //WHAT!?! override the SESSION with the post? without escaping?
$_SESSION['password']=$_POST['password']; //Same here!?!?!
//Now you decide the job_title
if ($array['job_title']=="user")
{ header ("location: userpage.php"); }
else if ($array['job_title']=="admin")
{ header ("location: adminpage.php"); }
}
else if ($name=="ahmedkamal8989#Epci" && $password=="epcisurvey2012#ahmed")
{ header ("location: adminpage.php"); }
else {
echo "Wrong user or password";
}
?>
So i made this code above like this
<?php
session_start();
$host="localhost"; // Host name
$username="ebarea_epic"; // Mysql username
$password="..."; // Mysql password
$db_name="ebarea_epic"; // Database name
$tbl_name="medicalrep"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$name=mysql_real_escape_string($_POST['name']);
$password=mysql_real_escape_string($_POST['password']);
$sql="SELECT `job_title` FROM $tbl_name WHERE name='$name' and password='$password' LIMIT 1";
$result = mysql_query($sql);
$num_results = mysql_num_rows($result);
if($num_results ==1)
{
$_SESSION['name']=$name;
$_SESSION['password']=$password;
$_SESSION['job_title']=$result[0];
switch($result[0])
{
case 'user':
$direct = 'userpage';
break;
case 'admin':
$direct = 'adminpage';
break;
default:
if ($name=="ahmedkamal8989#Epci" && $password=="epcisurvey2012#ahmed")
{
$direct = 'adminpage';
}
else
{
echo 'Wrong user or password';
die();
}
break;
}
header('location: '.$direct.'.php');
die();
?>
I didnt test this, but i hope you can fixed the bugs yourself ;)