I have two files connect.php and login.php. The login script returns a user_id or password error, but I know they are correct.
The DB connection seems to be working OK and I cannot see any specific fault in the PHP code in login.php.
Can anyone spot the error or point me in the right direction.?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Login</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<form class="form-signin">
<h2 class="form-signin-heading">Please sign in</h2>
<label for="user_id" class="sr-only">Email address</label>
<input type="email" id="user_id" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="password" class="form-control" placeholder="Password" required>
<div class="checkbox">
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Log-in</button>
</form>
</div> <!-- /container -->
<?php //start php tag
//include connect.php page for database connection
Include('connect.php');
//if submit is not blanked i.e. it is clicked.
if (isset($_REQUEST['Submit'])) //here give the name of your button on which you would like //to perform action.
{
// here check the submitted text box for null value by giving there name.
if($_REQUEST['user_id']=="" || $_REQUEST['password']=="")
{
echo " Field must be filled";
}
else
{
$sql1= "select * from users where email= '".$_REQUEST['user_id']."' && password ='".$_REQUEST['password']."'";
$result=mysql_query($sql1)
or exit("Sql Error".mysql_error());
$num_rows=mysql_num_rows($result);
if($num_rows>0)
{
// redirect
header("Location:ncr.php");
}
else
{
echo "username or password incorrect";
}
}
}
?>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
This is the DB connection, but it looks fine.
<?php
$hostname="localhost";
$username="xxx";
$password="xxxx";
$database="xxx";
$con=mysql_connect($hostname,$username,$password);
if(! $con)
{
die('Connection Failed'.mysql_error());
}
mysql_select_db($database,$con);
?>
In your html form must put the name of the input for the php can take the values:
<input type="email" name="user_id" id="user_id" class="form-control" placeholder="Email address" required autofocus>
<input type="password" name="password" id="password" class="form-control" placeholder="Password" required>
I hope it helps you...
Related
I just finished my login form, and everything seems to be working properly, except that when I try logging in, it redirects me back to the login page. I've tried multiple solutions but none work. Here is my code:
Mainpage.php
<?
include("index.php");
session_start();
if(!isset($_SESSION['id'])){
header("Location:index.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Cable Tech Guide</title>
<!-- Bootstrap -->
<link href ="css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
.hitsCounter {
position:bottom;
float:right;
}
</style>
</head>
<body>
<div class="container">
<div class="navbar navbar-inverse">
<div class="navbar-header">
Twin Cities
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Coding Guide</li>
<li>Cable Types</li>
<li>Drop Integrity</li>
</ul>
</div>
</div>
<div class="jumbotron">
<h2>Update!! 2/14</h2>
<p>Unfortanely, the login system is taking longer than expected. I will post another update within the week, to keep you guys updated.</p>
<p>I did add a drop integrity page for everybody to use, and I also updated the XH codes. Everybody enjoy!</p>
</div>
<div class="jumbotron">
<p>After the login system is up and running, I should be able to add some contact numbers on here.</p>
<p>Any other suggestions would be very helpful!</p>
</div>
<img class="hitsCounter" src="/Hits_Counter/gd-count.cgi?page=PageCounter&style=LED&x=16&y=24&nbdigits=1">
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
login.php
<?php
session_start();
if ($_GET["logout"]==1 AND $_SESSION['id']) { session_destroy();
$message="You have been logged out. Have a nice day!";
}
include("connection.php");
if ($_POST['submit']=="Sign Up") {
if (!$_POST['email']) $error.="<br />Please enter your email";
else if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) $error.="<br />Please enter a valid email";
$var1 = ($_POST['accessCode']);
$var2 = "abC";
if (strcmp($var1, $var2) !== 0) $error.="<br />That access code is incorrect!";
if (!$_POST['password']) $error.="<br />Please enter your password";
else {
if (strlen($_POST['password'])<8) $error.="<br />Please enter at least 8 characters";
if(!preg_match('/[A-Z]/', $_POST['password'])) $error.= "<br />Please include at least one capital letter";
}
if ($error) $error = "There were error(s) in your sign up details:".$error;
else {
$query= "SELECT * FROM `users` WHERE techNumber ='".mysqli_real_escape_string($link, $_POST['techNumber'])."'";
$result = mysqli_query($link, $query);
$results = mysqli_num_rows($result);
if ($results) $error = "That tech number is already registered. Do you want to log in?";
else {
$query = "INSERT INTO `users` (`techNumber`, `email`, `password`, `accessCode`) VALUES ('".mysqli_real_escape_string($link, $_POST['techNumber'])."', '".mysqli_real_escape_string($link, $_POST['email'])."', '".md5(md5($_POST['techNumber']).$_POST['password'])."', '".mysqli_real_escape_string($link, $_POST['accessCode'])."')";
mysqli_query($link, $query);
$_SESSION['id']= mysqli_insert_id($link);
header("Location:mainPage.php");
}
}
}
if ($_POST['submit'] == "Log In") {
$query = "SELECT * FROM users WHERE techNumber='".mysqli_real_escape_string($link, $_POST['logintechNumber'])."'AND password='" .md5(md5($_POST['logintechNumber']) .$_POST['loginpassword']). "'LIMIT 1";
$result = mysqli_query($link, $query);
$row = mysqli_fetch_array($result);
if($row){
$_SESSION['id']=$row['id'];
header("Location:mainPage.php");
} else {
$error = "We could not find a user with that tech number and password. Please try again.";
}
}
?>
index.php
<?php include("login.php"); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Cable Tech Guide</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
</style>
</head>
<body data-spy="scroll" data-target=".navbar-collapse">
<div class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Twin Cities</a>
</div>
<div class="collapse navbar-collapse">
<form class="navbar-form navbar-right" method="post">
<div class="form-group">
<input type="techNumber" name="logintechNumber" placeholder="Tech Number" class="form-control" value="<?php echo addslashes($_POST['logintechNumber']); ?>" />
</div>
<div class="form-group">
<input type="password" name="loginpassword" placeholder="Password" class="form-control" value="<?php echo addslashes($_POST['loginpassword']); ?>" />
</div>
<input type="submit" name= "submit" class="btn btn-success" value="Log In">
</form>
</div>
</div>
</div>
<div class="container contentContainer" id="topContainer">
<div class="row">
<div class="col-md-6 col-md-offset-3" id="topRow">
<h1 class="marginTop">Cable Tech Guide</h1>
<?php
if ($error) {
echo '<div class="alert alert-danger">'.addslashes($error).'</div>';
}
if ($message) {
echo '<div class="alert alert-success">'.addslashes($message).'</div>';
}
?>
<form class="marginTop" method="post">
<div class="form-group">
<label for="techNumber">Tech Number</label>
<input type="techNumber" name="techNumber" class="form-control" placeholder="Your Tech Number" value="<? echo addslashes($_POST['techNumber']); ?>" />
</div>
<div class="form-group">
<label for="email">Email Address</label>
<input type="email" name="email" class="form-control" placeholder="Your Email" value="<? echo addslashes($_POST['email']); ?>" />
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" class="form-control" placeholder="Password" value="<? echo addslashes($_POST['password']); ?>" />
</div>
<div class="form-group">
<label for="accessCode">Access Code</label>
<input type="accessCode" name="accessCode" class="form-control" placeholder="Access Code" value="<? echo addslashes($_POST['accessCode']); ?>" />
</div>
<input type="submit" name="submit" value="Sign Up" class="btn btn-success btn-lg marginTop"/>
</form>
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script>
$(".contentContainer").css("min-height",$(window).height());
</script>
</body>
</html>
As I observe your code..
I thought u have forget to open php tag properly on mainpage.php
you should use proper php open tag like this
<?php
pls chech it. this was your problem.
and make sure session_start(); always be first line of php code. so update ur code as like below. on mainpage.php
<?php
session_start();
if(!isset($_SESSION['id'])){
header("Location:index.php");
}
include("index.php");
?>
I cant understand your logic
but i hope its solve your session issue.
try it.
Sessions merely persist data across multiple requests to PHP, and the fact that this is an ideal place to store the user's authentication state does not mean that it should only be started during authentication.
Also, the name session_start() is a bit misleading because it does not start a session so much as open one if it exists, or start a new one. The first invocation to session_start() will set a cookie in the user's browser with the PHPSESSID variable that is passed back in the $_COOKIE superglobal array on subsequent requests. If session_start() detects this variable it loads the data from the server's session cache into $_SESSION, but only when session_start() is called.
This is why you should be calling session_start() for all requests, and why if should be one of the very first things in your script. Personally, all of my projects have the same 2 lines at the beginning of the global header:
Add session_start() on each page.
Echo session value so you can get idea that session started or not.
<?php
error_reporting(E_ALL);
session_start();
session_start(); will set cookies therefore should be called before any output. To make sure it will happen it should be the first thing called in anyone script that require use of the $_SESSION superglobal.
For more info check this answer
Have a look at this
Hope it will help and clear your doubts.
I cannot get the PHP code to run within the HTML code. It simply will not work and I can't figure it out. I removed the <head></head> part of the html and the PHP login script works again. How do I fix this?
Here is my PHP:
<?php
include("db.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from Form
$username = mysqli_real_escape_string($db,$_POST['username']);
$password = mysqli_real_escape_string($db,$_POST['password']);
$password = md5($password); // Encrypted Password
$sql = "SELECT id FROM Users WHERE username='$username' and passcode='$password'";
$result = mysqli_query($db,$sql);
$count = mysqli_num_rows($result);
// If result matched $username and $password, table row must be 1 row
if($count==1) {
header("location: greatjob.php");
}
else {
$error = "Your Login Name or Password is invalid";
}
}
?>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="test Portal | Login" />
<meta name="author" content="test" />
<title>test Portal | Login</title>
<link rel="stylesheet" href="logintemplate/js/jquery-ui/css/no-theme/jquery-ui-1.10.3.custom.min.css">
<link rel="stylesheet" href="logintemplate/css/font-icons/entypo/css/entypo.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Noto+Sans:400,700,400italic">
<link rel="stylesheet" href="logintemplate/css/bootstrap.css">
<link rel="stylesheet" href="logintemplate/css/neon-core.css">
<link rel="stylesheet" href="logintemplate/css/neon-theme.css">
<link rel="stylesheet" href="logintemplate/css/neon-forms.css">
<link rel="stylesheet" href="logintemplate/css/custom.css">
<script src="logintemplate/js/jquery-1.11.0.min.js"></script>
<script>$.noConflict();</script>
<!--[if lt IE 9]><script src="logintemplate/js/ie8-responsive-file-warning.js"></script><![endif]-->
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body class="page-body login-page login-form-fall" data-url="http://test.dev">
<!-- This is needed when you send requests via Ajax -->
<script type="text/javascript">
var baseurl = '';
</script>
<div class="login-container">
<div class="login-header login-caret">
<div class="login-content">
<a href="index.html" class="logo">
<img src="logintemplate/images/logo#2x.png" width="120" alt="" />
</a>
<p class="description">Dear user, log in to access the admin area!</p>
<!-- progress bar indicator -->
<div class="login-progressbar-indicator">
<h3>43%</h3>
<span>logging in...</span>
</div>
</div>
</div>
<div class="login-progressbar">
<div></div>
</div>
<div class="login-form">
<div class="login-content">
<div class="form-login-error">
<h3>Invalid login</h3>
<p><?PHP echo $error; ?></p>
</div>
<form method="post" action="login.php" role="form" id="form_login">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="entypo-user"></i>
</div>
<input type="text" class="form-control" name="username" id="username" placeholder="Username" autocomplete="off" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="entypo-key"></i>
</div>
<input type="password" class="form-control" name="password" id="password" placeholder="Password" autocomplete="off" />
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block btn-login">
<i class="entypo-login"></i>
Login In
</button>
</div>
</form>
<div class="login-bottom-links">
Forgot your password?
<br />
ToS - Privacy Policy
</div>
</div>
</div>
</div>
<!-- Bottom scripts (common) -->
<script src="logintemplate/js/gsap/main-gsap.js"></script>
<script src="logintemplate/js/jquery-ui/js/jquery-ui-1.10.3.minimal.min.js"></script>
<script src="logintemplate/js/bootstrap.js"></script>
<script src="logintemplate/js/joinable.js"></script>
<script src="logintemplate/js/resizeable.js"></script>
<script src="logintemplate/js/neon-api.js"></script>
<script src="logintemplate/js/jquery.validate.min.js"></script>
<script src="logintemplate/js/neon-login.js"></script>
<!-- JavaScripts initializations and stuff -->
<script src="logintemplate/js/neon-custom.js"></script>
<!-- Demo Settings -->
<script src="logintemplate/js/neon-demo.js"></script>
</body>
</html>
Based on your provided link, your site is using AJAX for login so the jQuery is preventing the form from submitting normally. To make it work do one of these:
Change where your ajax is pointing
Make your changes to the page that the AJAX is currently pointing to
Give the login form a different id like <form id="formlogin"> and the ajax will ignore it and reload your page the way you want it to.
I cannot seem to link my login page to my home page, any help would be much appreciated. I know its connecting to the database as i can create users but for some reason its not letting me sign in with a created user.
<?php require ("insert.php"); ?>
<?php
if(isset($_POST[ 'Login' ]))
{
$email= mysqli_real_escape_string($con, $_POST ['email']);
$pswrd= mysqli_real_escape_string($con, $_POST ['pswrd']);
$result = $con->query (" select * from users where email='$email' AND pswrd='$pswrd' ");
$row = $result->fetch_array(MYSQLI_BOTH);
session_start();
$_SESSION["User ID"] = $row['UserID'];
header ('Location: home.php');
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>AMSadler login</title>
<meta charset="utf-8">
<meta name="description" content="description of webpage">
<meta name="keywords" content="keywords go here">
<meta name="author" content="Anthony">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/login.css">
<link rel="index" href="index.php">
<link rel="icon" href="img/favicon.png" sizes="16x16" type="image/png">
</head>
<body>
<div class="header">
<div id="logo">
<img src="img/logo.png" alt="logo" title="AMSadler.com"/>
</div>
<div id="signup">
<button type="button">Sign up</button>
</div>
</div>
<div id="login">
<form>
<input type="text" name="email" placeholder="Email address">
<br>
<input type="password" name="password" placeholder="Password">
<br>
<input id="Login" type="submit" name="Login" value="Login">
</form>
</div>
<footer>
<div id="copyright">
<p>© Copyright 2015</p>
</div>
</footer>
</body>
</html>
You need to change your form tags.
From,
<form>
To,
<form action="yourPageName.php" method="post">
You need to specify your method type so in your PHP code you can get it using that method. If you leave out the method part it by default uses $_GET. Seeing as your code is pointing to $_POST then you set it to method="post".
You also need to set action="" this can be set to # for same page or leave it blank or using a file name. This will redirect the form to that page.
While the same concept is working on other forms for log in function, I'm unable to do so. Help me in login and register. Unable to execute this. Here is code of login and register form and hlater login.php page which should be used for login and register to database. All details are in the code. And kindly report the error and further modification require. Thanks in advance:
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6 lt8"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7 lt8"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8 lt8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8" />
<!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> -->
<title>Login and Registration Form T & P Cell</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Login and Registration Form with HTML5 and CSS3" />
<meta name="keywords" content="html5, css3, form, switch, animation, :target, pseudo-class" />
<meta name="author" content="Codrops" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/animate-custom.css" />
</head>
<body>
<div class="container">
<!-- Codrops top bar -->
<div class="codrops-top">
<span class="right">
</span>
</div><!--/ Codrops top bar -->
<section style=" height: 480px">
<div id="container_demo" >
<a class="hiddenanchor" id="toregister"></a>
<a class="hiddenanchor" id="tologin"></a>
<div id="wrapper">
<div id="login" class="animate form" style=" height: 270px">
<form action="login.php" method="POST" autocomplete="on">
<h1>Log in</h1>
<p>
<label for="username" class="uname" data-icon="u" > Your email or username </label>
<input id="username" name="username" required="required" type="text" />
</p>
<p>
<label for="password" class="youpasswd" data-icon="p"> Your password </label>
<input id="password" name="password" required="required" type="password" />
</p>
<p class="keeplogin">
<input type="checkbox" name="loginkeeping" id="loginkeeping" value="loginkeeping" />
<label for="loginkeeping">Keep me logged in</label>
</p>
<p class="login button" style="float: left">
Not a member? <a href="#toregister" class="to_register" > Join Us </a>
</p>
<p class="login button">
<input type="submit" value="Login" />
</p>
</form>
</div>
<div id="register" class="animate form" style=" height: 400px">
<form action="mysuperscript.php" autocomplete="on">
<h1> Sign up </h1>
<p>
<label for="usernamesignup" class="uname" data-icon="u"> Full name</label>
<input id="usernamesignup" name="usernamesignup" required="required" type="text" />
</p>
<p>
<label for="emailsignup" class="youmail" data-icon="e" > Your email</label>
<input id="emailsignup" name="emailsignup" required="required" type="email" />
</p>
<p>
<label for="passwordsignup" class="youpasswd" data-icon="p">Your password </label>
<input id="passwordsignup" name="passwordsignup" required="required" type="password" />
</p>
<p>
<label for="passwordsignup_confirm" class="youpasswd" data-icon="p">Please confirm your password </label>
<input id="passwordsignup_confirm" name="passwordsignup_confirm" required="required" type="password"/>
</p>
<p class="login button" style="float: left">
Already a member ?
Go and log in
</p>
<p class="signin button">
<input type="submit" value="Sign up"/>
</p>
</form>
</div>
</div>
</div>
</section>
</div>
</body>
</html>
<?php
session_start(); // Starting Session
$error = ''; // Variable To Store Error Message
if (isset($_POST['submit'])) {
echo "string6";
if (empty($_POST['username']) || empty($_POST['password'])) {
echo "gh";
$error = "Username or Password is invalid";
} else {
echo "asdfgh";
// Define $username and $password
$username = $_POST['username'];
$password = $_POST['password'];
// Establishing Connection with Server by passing server_name, user_id and password as a parameter
$connection = mysqli_connect("localhost", "root", "");
// To protect MySQL injection for Security purpose
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysqli_real_escape_string($username);
$password = mysqli_real_escape_string($password);
// Selecting Database
$db = mysqli_select_db("tandp_db", $connection);
// SQL query to fetch information of registerd users and finds user match.
$query = mysqli_query("select * from login where password='$password' AND username='$username'", $connection);
$rows = mysqli_num_rows($query);
if ($rows == 1) {
$_SESSION['login_user'] = $username; // Initializing Session
header("location:login.html"); // Redirecting To Other Page
} else {
$error = "Username or Password is invalid";
}
mysqli_close($connection); // Closing Connection
}
}
?>
in php code below in your script, you are checking this : if (isset($_POST['submit'])), so in the login form give name to submit button :
<input type="submit" name="submit" value="Login" />
Hi I just want to attach a style sheet to my custom template page. I don't want to add it to my header.php file. I want it inside my template file. How do I do this ?
I have added my custom template code below. I want to attach a external style sheet and I want to use it inside my custom template file.
Thanks in advance :)
<?php
/*
Template Name: User Registration
*/
?>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Registration Form</title>
<link rel="stylesheet" href="css/registration-style.css">
<!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]-->
</head>
<body>
<div class="container">
<section class="register">
<h1>Register on iMomen</h1>
<form method="post" action="index.html">
<div class="reg_section personal_info">
<h3>Your Personal Information</h3>
<input type="text" name="username" value="" placeholder="Your Desired Username">
<input type="text" name="email" value="" placeholder="Your E-mail Address">
</div>
<div class="reg_section password">
<h3>Your Password</h3>
<input type="password" name="password" value="" placeholder="Your Password">
<input type="password" name="confirm" value="" placeholder="Confirm Password">
</div>
<div class="reg_section password">
<h3>Your Address</h3>
<select>
<option value="">Egypt</option>
<option value="">Palastine</option>
<option value="">Syria</option>
<option value="">Italy</option>
</select>
<textarea name="textarea" id="">Your Full Address</textarea>
</div>
<p class="terms">
<label>
<input type="checkbox" name="remember_me" id="remember_me">
I accept iMomenTerms & Condition
</label>
</p>
<p class="submit"><input type="submit" name="commit" value="Sign Up"></p>
</form>
</section>
</div>
<section class="about">
Download it for free from iMomen
</section>
</body>
</html>
since your not using the wordpress header file!
whats stopping you just adding the link in your make shift code above?
<link rel="stylesheet" href="link-to-style.css">
if you use the theme header file, you could add the css on a page to page basis!
<?php if(is_page('custom-page')){?>
<link rel="stylesheet" href="link-to-style.css">
<?php } ?>
:)
in your template/page you can try this:
<link rel="stylesheet" href="<?php echo get_template_directory_uri().'/yourfolder/block.css' ?>">