Unable to connect phpMyAdmin database to my website - php

I am having trouble connecting a database i have created in phpMyAdmin to my web page using PHP. I am pretty sure my code is correct in both the html and php files and my DB and table names are correct, but when i try to use the registration form, it does nothing. I am using jQuery mobile, so have tried it with and without the data-ajax="false" attribute to no avail. What am i missing here? Thanks for any answers :) I have included the relevant html and php code below, it is the register form in the register page I am trying to connect to the DB.
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1; minimum-scale=1;">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<link href="/projects/ibill_v3/css/mainstyles.css" rel="StyleSheet"/>
<link href="/projects/ibill_v3/css/register.css" rel="StyleSheet"/>
<link href="/projects/ibill_v3/css/login.css" rel="StyleSheet"/>
<link href="/projects/ibill_v3/css/home.css" rel="StyleSheet"/>
<link href="/projects/ibill_v3/css/record_session.css" rel="StyleSheet"/>
<link href="/projects/ibill_v3/css/viewsessions.css" rel="StyleSheet"/>
<link href="/projects/ibill_v3/css/email.css" rel="StyleSheet"/>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="script.js"></script>
<script type='text/javascript' src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script type='text/javascript'>
$(document).on('pageinit', function(){
$('#registerForm').validate({ // initialize the plugin
// rules & options
});
});
</script>
<script type='text/javascript'>
$(document).on('pageinit', function(){
$('.loginform').validate({ // initialize the plugin
// rules & options
});
});
</script>
</head>
<body>
<!--********************************REGISTER PAGE**********************************************-->
<!--****************************************************************************************-->
<!--********************************HEADER**********************************************-->
<div data-role="page" id="register">
<div data-role="header" data-id="foo1" data-position="fixed">
<div class='cssmenu'>
<ul>
<li class='active'><a href='#home'>Home</a></li>
<li><a href='#sessionrecord'>Record a Session</a></li>
<li><a href='#viewsessions'>View Sessions</a></li>
<li><a href='#email'>E-mail an Invoice</a></li>
</ul>
</div>
</div>
<!--********************************HEADER**********************************************-->
<!--********************************MAIN**********************************************-->
<div data-role="main" class="ui-content">
<img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
<section class="registerform">
<h1>The iBill Invoicing App for Activity Instructors</h1>
<p>Register below</p>
<form data-ajax="false" method="POST" action="register.php" >
<ul>
<li>
<label for="username">Username</label>
<input type="text" name="username" id="username" class="required" minlength="5" placeholder="enter username (min-5 characters)">
</li>
<li>
<label for="firstname">Firstname</label>
<input type="text" name="firstname" id="firstname" class="required" minlength="5" placeholder="enter firstname">
</li>
<li>
<label for="username">Surname</label>
<input type="text" name="surname" id="surname" class="required" minlength="5" placeholder="enter surname">
</li>
<li>
<label for="email">Email</label>
<input type="email" name="email" id="email" class="required email" placeholder="yourname#email.com">
</li>
<li>
<label for="password">Password</label>
<input type="password" name="password" id="password" class="required" minlength="6" placeholder="enter password">
</li>
<li>
<label for="confirmpassword">Confirm Password</label>
<input type="password" name="confirmpassword" id="confirmpassword" class="required" minlength="6" placeholder="re-enter password">
</li>
<div id="registerbutton">
<input type="submit" value="Register">
</div>
</ul>
</form>
</section>
</div>
<!--********************************MAIN**********************************************-->
<!--********************************FOOTER**********************************************-->
<div data-role="footer">
<footer class="footer">
<p>awilliams©</p>
</footer>
</div>
</div>
<!--********************************REGISTER PAGE**********************************************-->
<!--****************************************************************************************-->
<!--********************************LOGIN PAGE**********************************************-->
<!--****************************************************************************************-->
<!--********************************HEADER**********************************************-->
<div data-role="page" id="login">
<div data-role="header" data-id="foo1" data-position="fixed">
<div class='cssmenu'>
<ul>
<li class='active'><a href='#home'>Home</a></li>
<li><a href='#sessionrecord'>Record a Session</a></li>
<li><a href='#viewsessions'>View Sessions</a></li>
<li><a href='#email'>E-mail an Invoice</a></li>
</ul>
</div>
</div>
<!--********************************HEADER**********************************************-->
<!--********************************MAIN**********************************************-->
<div data-role="main" class="ui-content">
<img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
<section class="loginform">
<form action="form.php" method="post">
<ul>
<li><label for="usermail">Email</label>
<input type="email" name="usermail" placeholder="yourname#email.com" class="required"></li>
<li><label for="password">Password</label>
<input type="password" name="password" placeholder="enter password" minlength="6"></li>
<li>
<div id="loginbutton">
<input type="submit" value="Login"></li>
</div>
<div id="registerbutton">
<input type="submit" value="Register"></li>
</div>
</ul>
</form>
</section>
</div>
<!--********************************MAIN**********************************************-->
<!--********************************FOOTER**********************************************-->
<div data-role="footer">
<footer class="footer">
<p>awilliams©</p>
</footer>
</div>
</div>
<!--********************************LOGIN PAGE**********************************************-->
<!--****************************************************************************************-->
<!--********************************HOME PAGE**********************************************-->
<!--***************************************************************************************-->
<!--********************************HEADER**********************************************-->
<div data-role="page" id="home">
<div data-role="header" data-id="foo1" data-position="fixed">
<div class='cssmenu'>
<ul>
<li class='active'><a href='#home'>Home</a></li>
<li><a href='#sessionrecord'>Record a Session</a></li>
<li><a href='#viewsessions'>View Sessions</a></li>
<li><a href='#email'>E-mail an Invoice</a></li>
</ul>
</div>
</div><!-- /header -->
<!--********************************HEADER**********************************************-->
<!--********************************MAIN**********************************************-->
<div data-role="main" class="ui-content">
<img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
<section class="maincontent">
<h1>The iBill Invoicing App for Activity Instructors</h1>
<p>iBill is a cross-platform app that allows you track and manage activity sessions on the go.</p>
<br>
<p>Record an activity session to get started!</p>
<div style="text-align:center">
Record a Session
</div>
</section>
</div>
<!--********************************MAIN**********************************************-->
<!--********************************FOOTER**********************************************-->
<div data-role="footer">
<footer class="footer">
<p>awilliams©</p>
</footer>
</div>
</div>
<!--********************************FOOTER**********************************************-->
<!--********************************HOME PAGE**********************************************-->
<!--***************************************************************************************-->
<!--********************************RECORD SESSION PAGE************************************-->
<!--***************************************************************************************-->
<!--********************************HEADER**********************************************-->
<div data-role="page" id="sessionrecord">
<div data-role="header" data-id="foo1" data-position="fixed">
<div class='cssmenu'>
<ul>
<li class='active'><a href='#home'>Home</a></li>
<li><a href='#sessionrecord'>Record a Session</a></li>
<li><a href='#viewsessions'>View Sessions</a></li>
<li><a href='#email'>E-mail an Invoice</a></li>
</ul>
</div>
</div><!-- /header -->
<!--********************************HEADER**********************************************-->
<!--********************************MAIN**********************************************-->
<div data-role="main" class="ui-content">
<img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
<section class="maincontent">
<h1>Record a session using the form below</h1>
<form method="post" action="" id="sessionRecord">
<fieldset>
<select name="typeofactivity" id="typeofactivity" data-native-menu="false">
<option>Type of Session</option>
<option value="surf">Surf</option>
<option value="coast">Coasteer</option>
<option value="bodyboard">Bodyboard</option>
<option value="climbing">Cornish Challenge</option>
</select>
</fieldset>
<fieldset>
<select name="employer" id="employer" data-native-menu="false">
<option>Employer</option>
<option value="nac">Newquay Activity Centre</option>
<option value="coastline">Coastline Coasteer</option>
</select>
</fieldset>
<form method="post" action="PHP HERE!">
<label for="datetime">Date and Time of Session</label>
<input type="datetime-local" data-clear-btn="false" name="datetime" id="datetime" value="">
</form>
<form method="post" action="PHP HERE!">
<label for="amount">Amount (GBP)</label>
<input type="number" data-clear-btn="true" name="amount" id="amount" value="">
</form>
<div id="submitbutton">
<input type="submit" value="Submit">
</div>
</form>
</section>
</div>
<!--********************************MAIN**********************************************-->
<!--********************************FOOTER**********************************************-->
<div data-role="footer">
<footer class="footer">
<p>awilliams©</p>
</footer>
</div>
</div>
<!--********************************FOOTER**********************************************-->
<!--********************************RECORD SESSION PAGE************************************-->
<!--***************************************************************************************-->
<!--********************************VIEW SESSIONS PAGE************************************-->
<!--***************************************************************************************-->
<!--********************************HEADER**********************************************-->
<div data-role="page" id="viewsessions">
<div data-role="header" data-id="foo1" data-position="fixed">
<div class='cssmenu'>
<ul>
<li class='active'><a href='#home'>Home</a></li>
<li><a href='#sessionrecord'>Record a Session</a></li>
<li><a href='#viewsessions'>View Sessions</a></li>
<li><a href='#email'>E-mail an Invoice</a></li>
</ul>
</div>
</div><!-- /header -->
<!--********************************HEADER**********************************************-->
<!--********************************MAIN**********************************************-->
<div data-role="main" class="ui-content">
<img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
<section class="maincontent">
<!--MAIN CONTENT GOES HERE-->
</section>
</div>
<!--********************************MAIN**********************************************-->
<!--********************************FOOTER**********************************************-->
<div data-role="footer">
<footer class="footer">
<p>awilliams©</p>
</footer>
</div>
</div>
<!--********************************FOOTER**********************************************-->
<!--********************************VIEW SESSIONS PAGE************************************-->
<!--***************************************************************************************-->
<!--********************************EMAIL AN INVOICE PAGE************************************-->
<!--***************************************************************************************-->
<!--********************************HEADER**********************************************-->
<div data-role="page" id="email">
<div data-role="header" data-id="foo1" data-position="fixed">
<div class='cssmenu'>
<ul>
<li class='active'><a href='#home'>Home</a></li>
<li><a href='#sessionrecord'>Record a Session</a></li>
<li><a href='#viewsessions'>View Sessions</a></li>
<li><a href='#email'>E-mail an Invoice</a></li>
</ul>
</div>
</div><!-- /header -->
<!--********************************HEADER**********************************************-->
<!--********************************MAIN**********************************************-->
<div data-role="main" class="ui-content">
<img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
<section class="maincontent">
<!--MAIN CONTENT GOES HERE-->
</section>
</div>
<!--********************************MAIN**********************************************-->
<!--********************************FOOTER**********************************************-->
<div data-role="footer">
<footer class="footer">
<p>awilliams©</p>
</footer>
</div>
</div>
<!--********************************FOOTER**********************************************-->
<!--********************************EMAIL AN INVOICE PAGE************************************-->
<!--***************************************************************************************-->
</body>
<?php
$servername = "localhost";
$username = "root";
$password = "cornwall";
$con=mysqli_connect('localhost','root','cornwall','ibill');
// This code creates a connec'tion to the MySQL database in PHPMyAdmin named 'ibill':
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// The connection is then checked, if it fails, an echo is sent back to the page stating a connection error.
$username = $_POST['username'];
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
$emailaddress = $_POST['emailaddress'];
$password = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
//These are the different PHP variables that store my posted data.
$register="INSERT INTO user_details (username, firstname, surname, emailaddress, password,) VALUES ('$username', '$firstname', '$surname', '$emailaddress', '$password')";
echo $register;
$result=mysqli_query($con, $register);
//This is the query that will be sent to the MySQL server.
header('Location: http://localhost/projects/ibill_v3/html/main.html#login');
exit();
//This directs the user to the relevant page after successful registration.
?>

First of all, read this article about SQL injection: How can I prevent SQL injection in PHP?.
There is an error in you SQL query. In your PHP file, replace this line:
$result=mysqli_query($con, $register);
with this:
if(mysqli_query($con,$register) === FALSE){
echo mysqli_error($con);
}
To display errors in PHP code, add these lines:
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
Ref: How do I get PHP errors to display?

Related

PHP Login just refreshes page no error

Hello I seem to be having a very frustrating problem with my login which i cannot seem to fix as there is no error output.I seem to have fixed this problem on my mac but i transfered the exact files over to my windows pc and its stopped working again. whenever I try and login with the example a#a.com and password a is seems to just refresh the page over and over no matter how many times I have tried.I was wondering if anyone could help with this error?
I have tried adding the action to login.php it seems to make no difference.
picture of table im taking data from:
session.php:
<?php
include('config.php');
session_start();
$user_check = $_SESSION['login_user'];
$ses_sql = mysqli_query($conn,"select email_adress from customer where email_adress = '$user_check' ");
$row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
$login_session = $row['email_adress'];
if(!isset($_SESSION['login_user'])){
header("location:login.php");
}
?>
login.php
<?php
include("config.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from form
$myusername = mysqli_real_escape_string($conn,$_POST['username']);
$mypassword = mysqli_real_escape_string($conn,$_POST['password']);
$sql = "SELECT customer_id FROM customer WHERE email_adress = '$myusername' and password = '$mypassword'";
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$active = $row['customer_id'];
$count = mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count == 1) {
$_SESSION['login_user'] = $myusername;
header("location: index2.php");
}else {
$error = "Your Login Name or Password is invalid";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login | Bid4MyJob</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Bid4MyJob">
<meta name="author" content="James Wood">
<!-- CSS -->
<link href="assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="assets/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="assets/css/main.css" rel="stylesheet" type="text/css">
<link href="assets/css/my-custom-styles.css" rel="stylesheet" type="text/css">
<!-- IE 9 Fallback-->
<!--[if IE 9]>
<link href="assets/css/ie.css" rel="stylesheet">
<![endif]-->
<!-- GOOGLE FONTS -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400italic,400,600,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:300,300italic,400italic,700,400,300' rel='stylesheet' type='text/css'>
<!-- FAVICONS -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/repute144x144.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/repute114x114.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/repute72x72.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/repute57x57.png">
<link rel="shortcut icon" href="assets/ico/favicon.png">
</head>
<body>
<!-- WRAPPER -->
<div class="wrapper">
<!-- NAVBAR -->
<nav class="navbar navbar-default " role="navigation">
<div class="container">
<!-- TOPBAR -->
<div class="topbar">
<ul class="list-inline top-nav">
<li>
<div class="btn-group">
<button type="button" class="btn btn-link dropdown-toggle btn-xs" data-toggle="dropdown"><img src="assets/img/flags/United-Kingdom.png" alt="United Kingdom"> United Kingdom <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right country-selector" role="menu">
<li>
<img src="assets/img/flags/United-Kingdom.png" alt="United Kingdom"> United Kingdom
</li>
<li>
<img src="assets/img/flags/Japan.png" alt="Japan"> Japan
</li>
<li>
<img src="assets/img/flags/China.png" alt="China"> China
</li>
<li>
<img src="assets/img/flags/Germany.png" alt="Germany"> Germany
</li>
</ul>
</div>
</li>
<li>Help</li>
<li>Support</li>
</ul>
<div class="searchbox">
<form method="post">
<div class="input-group input-group-sm">
<input type="text" class="form-control" placeholder="search ...">
<span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-search"></i></button>
</span>
</div>
</form>
</div>
</div>
<!-- END TOPBAR -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-nav">
<span class="sr-only">Toggle Navigation</span>
<i class="fa fa-bars"></i>
</button>
<a href="index.html" class="navbar-brand navbar-logo navbar-logo-bigger">
</a>
</div>
<!-- MAIN NAVIGATION -->
<div id="main-nav" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>
HOME
</li>
<li>
HOW IT WORKS
</li>
<li>
POST JOB
</li>
<li>
FIND JOB
</li>
<li>
SIGN UP
</li>
<li>
LOGIN
</li>
</ul>
</div>
<!-- END MAIN NAVIGATION -->
</div>
</nav>
<!-- END NAVBAR -->
<!-- BREADCRUMBS -->
<div class="page-header">
<div class="container">
<h1 class="page-title pull-left">Login</h1>
<ol class="breadcrumb">
<li>Home</li>
<li class="active">Login</li>
</ol>
</div>
</div>
<!-- END BREADCRUMBS -->
<!-- PAGE CONTENT -->
<div class="page-content">
<div class="col-md-6">
<!-- LOGIN FORM -->
<h2 class="section-heading">Login Form</h2>
<form class="form-horizontal" role="form" action = "login.php" method = "post">
<div class="form-group">
<label for="username" class="control-label sr-only">Email</label>
<div class="col-sm-12">
<div class="input-group">
<input type="email" class="form-control" id="username" name = "username" placeholder="Email">
<span class="input-group-addon"><i class="fa fa-envelope"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label for="password" class="control-label sr-only">Password</label>
<div class="col-sm-12">
<div class="input-group">
<input type="password" class="form-control" id="password" name="password" placeholder="Password">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<label class="fancy-checkbox">
<input type="checkbox">
<span>Remember me</span>
</label>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<button type="submit" class="btn btn-primary"><i class="fa fa-sign-in"></i> Sign in</button>
</div>
</div>
</form>
<br>
<p><em>Don't have an account yet?</em> <strong>Sign Up</strong>
<br>
<em>Forgot your password?</em> Recover Password</p>
<!-- END LOGIN FORM -->
</div>
</div>
<br>
<br>
<div class="row">
<div class="col-md-6">
<!-- LOGIN FORM WITH LABEL -->
<!-- END LOGIN FORM WITH LABEL -->
</div>
<div class="col-md-6">
<!-- SIMPLE FORM -->
<!-- END SIMPLE FORM -->
</div>
</div>
<br>
<br>
<!-- INLINE FORM -->
<!-- END INLINE FORM -->
</div>
</div>
</div>
</div>
<!-- END PAGE CONTENT -->
<!-- FOOTER -->
<footer>
<div class="container">
<div class="row">
<div class="col-md-4">
<!-- COLUMN 1 -->
<h3 class="sr-only">ABOUT US</h3>
<img src="assets/img/logo/repute-logo-light.png" class="logo" alt="Repute">
<p>Proactively aggregate B2B initiatives before extensive channels. Monotonectally extend interactive methods of empowerment through excellent applications. Rapidiously synergize visionary products with sticky technology.</p>
<br>
<address class="margin-bottom-30px">
<ul class="list-unstyled">
<li>Unit 5, Block B Nesfield Road
<br/> Colchester, Essex CO4 3ZL 222222</li>
<li>Phone: 01206 588 000</li>
<li>Email: sales#universalwebdesign.co.uk</li>
</ul>
</address>
<!-- END COLUMN 1 -->
</div>
<div class="col-md-4">
<!-- COLUMN 2 -->
<h3 class="footer-heading">USEFUL LINKS</h3>
<div class="row margin-bottom-30px">
<div class="col-xs-6">
<ul class="list-unstyled footer-nav">
<li>About Us</li>
<li>News</li>
<li>Community</li>
<li>Career</li>
<li>Blog</li>
</ul>
</div>
<div class="col-xs-6">
<ul class="list-unstyled footer-nav">
<li>Press Kit</li>
<li>FAQ</li>
<li>Terms</li>
<li>Privacy Policy</li>
<li>Contact Us</li>
</ul>
</div>
</div>
<!-- END COLUMN 2 -->
</div>
<div class="col-md-4">
<!-- COLUMN 3 -->
<div class="newsletter">
<h3 class="footer-heading">NEWSLETTER</h3>
<p>Get the latest update from us by subscribing to our newsletter.</p>
<form class="newsletter-form" method="POST">
<div class="input-group input-group-lg">
<input type="email" class="form-control" name="email" placeholder="youremail#domain.com">
<span class="input-group-btn"><button class="btn btn-primary" type="button"><i class="fa fa-spinner fa-spin"></i><span>SUBSCRIBE</span></button>
</span>
</div>
<div class="alert"></div>
</form>
</div>
<div class="social-connect">
<h3 class="footer-heading">GET CONNECTED</h3>
<ul class="list-inline social-icons">
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-google-plus"></i></li>
<li><i class="fa fa-rss"></i></li>
</ul>
</div>
<!-- END COLUMN 3 -->
</div>
</div>
</div>
<!-- COPYRIGHT -->
<div class="text-center copyright">
©2018 Bid4MyJob. All Rights Reserved.
</div>
<!-- END COPYRIGHT -->
</footer>
<!-- END FOOTER -->
</div>
<!-- END WRAPPER -->
<!-- JAVASCRIPTS -->
<script src="assets/js/jquery-2.1.1.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/plugins/autohidingnavbar/jquery.bootstrap-autohidingnavbar.min.js"></script>
<script src="assets/js/repute-scripts.js"></script>
</body>
</html>
You run the query:
$sql = "SELECT customer_id FROM customer WHERE email_adress = 'a#a.com' and password = 'a'";
this returns multiple results for $count = mysqli_num_rows($result); is thus > 1.
So you always fall into the else:
if($count == 1) {
$_SESSION['login_user'] = $myusername;
header("location: index2.php");
}else {
$error = "Your Login Name or Password is invalid";
}
Try for testing purposes try:
if($count >= 1) {
$_SESSION['login_user'] = $myusername;
header("location: index2.php");
}else {
$error = "Your Login Name or Password is invalid";
}
ofc later you will have to make sure you can't sign up email addresses twice.
Secondly you might want to forward to your session.php instead?
header("location:session.php"); // instead of index2.php

How to use PHP display unique user data to a html page

currently I have a website with a basic login, I was just wondering how I would display a the name,skill and description of the unique user who is logged in.This is what I have done so far.I can only find articles on how to display data into table.This is the updated code:
<?php
include('session.php');
require 'config.php';
$sql = "SELECT * FROM profile";
$result = $conn->query($sql);
//echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="profile.css">
</head>
<body>
<ul>
<li>Home</li>
<li>PostJob</li>
<li>Find Job</li>
<li>How It Works</li>
<li>Notifications</li>
<li>Message</li>
<li>profile</li>
</ul>
<h1>Welcome To Bid4MyJob</h1>
<li>edit profile</li>
<div id="ProfilePage">
<div id="LeftCol">
<div id="Photo"></div>
<div id="ProfileOptions">
a
</div>
</div>
<div id="Info">
<p>
<strong>Name:<?php echo $row["name"]?></strong>
<!--<span>James</span>-->
</p>
<p>
<strong>Skill:<?php echo $row["skill"]?><</strong>
<!--span>James</span>-->
</p>
<!-- <p>
<strong>review:<?php /*echo $row["review"]*/?><</strong>
<span>james</span>
</p> -->
<p>
<strong>Description:<?php echo $row["description"]?><</strong>
<span>James</span>
</p>
<!--<p>
<strong>Name:</strong>
<span>james</span>
</p>-->
</div>
<!-- Needed because other elements inside ProfilePage have floats
<div style="clear:both"></div>-->
</div>
</body>
</html>
Picture of database table:
https://imgur.com/a/XYTLY
Session.php:
<?php
include('config.php');
session_start();
$user_check = $_SESSION['login_user'];
$ses_sql = mysqli_query($conn,"select email_adress from customer where email_adress = '$user_check' ");
$row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
$login_session = $row['email_adress'];
if(!isset($_SESSION['login_user'])){
header("location:login.php");
}
?>
Login.php:
<?php
include("config.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from form
$myusername = mysqli_real_escape_string($conn,$_POST['username']);
$mypassword = mysqli_real_escape_string($conn,$_POST['password']);
$sql = "SELECT customer_id FROM customer WHERE email_adress = '$myusername' and password = '$mypassword'";
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$active = $row['customer_id'];
$count = mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count == 1) {
$_SESSION['login_user'] = $myusername;
header("location: index2.php");
}else {
$error = "Your Login Name or Password is invalid";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login | Bid4MyJob</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Bid4MyJob">
<meta name="author" content="James Wood">
<!-- CSS -->
<link href="assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="assets/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="assets/css/main.css" rel="stylesheet" type="text/css">
<link href="assets/css/my-custom-styles.css" rel="stylesheet" type="text/css">
<!-- IE 9 Fallback-->
<!--[if IE 9]>
<link href="assets/css/ie.css" rel="stylesheet">
<![endif]-->
<!-- GOOGLE FONTS -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400italic,400,600,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:300,300italic,400italic,700,400,300' rel='stylesheet' type='text/css'>
<!-- FAVICONS -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/repute144x144.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/repute114x114.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/repute72x72.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/repute57x57.png">
<link rel="shortcut icon" href="assets/ico/favicon.png">
</head>
<body>
<!-- WRAPPER -->
<div class="wrapper">
<!-- NAVBAR -->
<nav class="navbar navbar-default " role="navigation">
<div class="container">
<!-- TOPBAR -->
<div class="topbar">
<ul class="list-inline top-nav">
<li>
<div class="btn-group">
<button type="button" class="btn btn-link dropdown-toggle btn-xs" data-toggle="dropdown"><img src="assets/img/flags/United-Kingdom.png" alt="United Kingdom"> United Kingdom <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right country-selector" role="menu">
<li>
<img src="assets/img/flags/United-Kingdom.png" alt="United Kingdom"> United Kingdom
</li>
<li>
<img src="assets/img/flags/Japan.png" alt="Japan"> Japan
</li>
<li>
<img src="assets/img/flags/China.png" alt="China"> China
</li>
<li>
<img src="assets/img/flags/Germany.png" alt="Germany"> Germany
</li>
</ul>
</div>
</li>
<li>Help</li>
<li>Support</li>
</ul>
<div class="searchbox">
<form method="post">
<div class="input-group input-group-sm">
<input type="text" class="form-control" placeholder="search ...">
<span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-search"></i></button>
</span>
</div>
</form>
</div>
</div>
<!-- END TOPBAR -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-nav">
<span class="sr-only">Toggle Navigation</span>
<i class="fa fa-bars"></i>
</button>
<a href="index.html" class="navbar-brand navbar-logo navbar-logo-bigger">
</a>
</div>
<!-- MAIN NAVIGATION -->
<div id="main-nav" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>
HOME
</li>
<li>
HOW IT WORKS
</li>
<li>
POST JOB
</li>
<li>
FIND JOB
</li>
<li>
SIGN UP
</li>
<li>
LOGIN
</li>
</ul>
</div>
<!-- END MAIN NAVIGATION -->
</div>
</nav>
<!-- END NAVBAR -->
<!-- BREADCRUMBS -->
<div class="page-header">
<div class="container">
<h1 class="page-title pull-left">Login</h1>
<ol class="breadcrumb">
<li>Home</li>
<li class="active">Login</li>
</ol>
</div>
</div>
<!-- END BREADCRUMBS -->
<!-- PAGE CONTENT -->
<div class="page-content">
<div class="col-md-6">
<!-- LOGIN FORM -->
<h2 class="section-heading">Login Form</h2>
<form class="form-horizontal" role="form" action = "" method = "post">
<div class="form-group">
<label for="username" class="control-label sr-only">Email</label>
<div class="col-sm-12">
<div class="input-group">
<input type="email" class="form-control" id="username" name = "username" placeholder="Email">
<span class="input-group-addon"><i class="fa fa-envelope"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label for="password" class="control-label sr-only">Password</label>
<div class="col-sm-12">
<div class="input-group">
<input type="password" class="form-control" id="password" name="password" placeholder="Password">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<label class="fancy-checkbox">
<input type="checkbox">
<span>Remember me</span>
</label>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<button type="submit" class="btn btn-primary"><i class="fa fa-sign-in"></i> Sign in</button>
</div>
</div>
</form>
<br>
<p><em>Don't have an account yet?</em> <strong>Sign Up</strong>
<br>
<em>Forgot your password?</em> Recover Password</p>
<!-- END LOGIN FORM -->
</div>
</div>
<br>
<br>
<div class="row">
<div class="col-md-6">
<!-- LOGIN FORM WITH LABEL -->
<!-- END LOGIN FORM WITH LABEL -->
</div>
<div class="col-md-6">
<!-- SIMPLE FORM -->
<!-- END SIMPLE FORM -->
</div>
</div>
<br>
<br>
<!-- INLINE FORM -->
<!-- END INLINE FORM -->
</div>
</div>
</div>
</div>
<!-- END PAGE CONTENT -->
<!-- FOOTER -->
<footer>
<div class="container">
<div class="row">
<div class="col-md-4">
<!-- COLUMN 1 -->
<h3 class="sr-only">ABOUT US</h3>
<img src="assets/img/logo/repute-logo-light.png" class="logo" alt="Repute">
<p>Proactively aggregate B2B initiatives before extensive channels. Monotonectally extend interactive methods of empowerment through excellent applications. Rapidiously synergize visionary products with sticky technology.</p>
<br>
<address class="margin-bottom-30px">
<ul class="list-unstyled">
<li>Unit 5, Block B Nesfield Road
<br/> Colchester, Essex CO4 3ZL 222222</li>
<li>Phone: 01206 588 000</li>
<li>Email: sales#universalwebdesign.co.uk</li>
</ul>
</address>
<!-- END COLUMN 1 -->
</div>
<div class="col-md-4">
<!-- COLUMN 2 -->
<h3 class="footer-heading">USEFUL LINKS</h3>
<div class="row margin-bottom-30px">
<div class="col-xs-6">
<ul class="list-unstyled footer-nav">
<li>About Us</li>
<li>News</li>
<li>Community</li>
<li>Career</li>
<li>Blog</li>
</ul>
</div>
<div class="col-xs-6">
<ul class="list-unstyled footer-nav">
<li>Press Kit</li>
<li>FAQ</li>
<li>Terms</li>
<li>Privacy Policy</li>
<li>Contact Us</li>
</ul>
</div>
</div>
<!-- END COLUMN 2 -->
</div>
<div class="col-md-4">
<!-- COLUMN 3 -->
<div class="newsletter">
<h3 class="footer-heading">NEWSLETTER</h3>
<p>Get the latest update from us by subscribing to our newsletter.</p>
<form class="newsletter-form" method="POST">
<div class="input-group input-group-lg">
<input type="email" class="form-control" name="email" placeholder="youremail#domain.com">
<span class="input-group-btn"><button class="btn btn-primary" type="button"><i class="fa fa-spinner fa-spin"></i><span>SUBSCRIBE</span></button>
</span>
</div>
<div class="alert"></div>
</form>
</div>
<div class="social-connect">
<h3 class="footer-heading">GET CONNECTED</h3>
<ul class="list-inline social-icons">
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-google-plus"></i></li>
<li><i class="fa fa-rss"></i></li>
</ul>
</div>
<!-- END COLUMN 3 -->
</div>
</div>
</div>
<!-- COPYRIGHT -->
<div class="text-center copyright">
©2018 Bid4MyJob. All Rights Reserved.
</div>
<!-- END COPYRIGHT -->
</footer>
<!-- END FOOTER -->
</div>
<!-- END WRAPPER -->
<!-- JAVASCRIPTS -->
<script src="assets/js/jquery-2.1.1.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/plugins/autohidingnavbar/jquery.bootstrap-autohidingnavbar.min.js"></script>
<script src="assets/js/repute-scripts.js"></script>
</body>
</html>
You need a field on Profile that links to the customer table (or viceversa).
email can be in both tables, then you can link to your $login_session
SELECT * FROM profile WHERE email = '$login_session' LIMIT 1
In this case, take care and do not let users to change their email (without verification they own it) and do not let create a new account with the same credentials as another one.
But as a good practice on DB, it is better to have profile_id on customer
session.php
$ses_sql = mysqli_query($conn,"select email_adress, profile_id from customer where email_adress = '$user_check' ");
index.php
$sql = "SELECT * FROM profile WHERE profile_id = $profile_id LIMIT 1";
BTW:
- Try to separate concerns, between database and presentation layer. You should read more about MVC.

dropdown is not selecting selected option in php while editing

i'm selecting option while adding,but selected option is not in edit dropdown.What will be the issue?
Edit Appointment.php:
<?php
include_once 'config.php';
$id = $_REQUEST['id'];
$query="SELECT p.*,u.fileno FROM patients AS p,users AS u WHERE p.id_patient='$id' AND p.users_id_user=u.id_user";
$resultPatient=$db->select($query);
if(isset($_POST['requesttype'])&&$_POST['requesttype'] == 'editPatient'){
$updateInfo=array();
$updateInfo['name'] = $_REQUEST['name'];
$updateInfo['email'] = $_REQUEST['email'];
$updateInfo['age'] = $_REQUEST['age'];
/*$updateInfo['age'] = $_REQUEST['age'];
$updateInfo['gender'] = $_REQUEST['gender'];*/
$updateInfo['phone'] = str_replace(array('(',')',' ','-'), array('','','',''),$_REQUEST['phone']);
$updateInfo['date'] = date('d-m-Y', strtotime($_REQUEST['date']));
$updateInfo['time'] = $_REQUEST['time'];
$updateInfo['confirm_status'] = 'c';
$date=date('Y-m-d H:i:s');
$updateInfo['date_updated']=$date;
$updateCondition=" id_patient='".$id."'";
$res=$db->update('patients', $updateInfo,$updateCondition);
$id=$resultPatient[0]['users_id_user'];
$where="t.users_id_user='$id' AND";
$query="SELECT t.device_id,t.platforms_id_platform as id_platform FROM tokens as t WHERE $where t.device_id!=''";
$resultTokens=$db->select($query);
if($resultTokens)
{
include_once 'Gcm.php';
include_once 'Apns.php';
$deviceTokens=array();
$deviceTokens1=array();
$alert='Your appointment is confirmed on '.$updateInfo['date'].' at '.$updateInfo['time'];
foreach($resultTokens as $token)
{
if($token['id_platform']=='1'&&$token['device_id']!='')
$deviceTokens[]=$token['device_id'];
if($token['id_platform']=='2'&&$token['device_id']!='')
$deviceTokens1[]=$token['device_id'];
}
if(count($deviceTokens)>0)
{
$apns=new Apns();
$apns->apnsPush($deviceTokens,$alert);
}
if(count($deviceTokens1)>0)
{
$gcm = new GCM();
$message = array("m" => $alert);
$result = $gcm->send_notification($deviceTokens1,$message);
}
}
header("Location:appointments.php?m=u");
}
$querySlot = "SELECT * FROM slots";
$resultSlot=$db->select($querySlot);
$query="select * from photos where type='service'";
$resultUsers1=$db->select($query);
include_once 'header.php';
?>
<script type="text/javascript" src="js/jquery.timepicker.js"></script>
<link rel="stylesheet" type="text/css" href="js/jquery.timepicker.css" />
<script>
$(function() {
$('#basicExample').timepicker();
});
</script>
<!-- Sidebar begins -->
<div id="sidebar">
<!-- Left Main menu begins -->
<?php include_once 'menu.php'; ?>
<!-- Left Main menu ends -->
<!-- Secondary nav -->
<div class="secNav">
<div class="secWrapper">
<!--div class="secTop">
</div-->
<!-- Tabs container -->
<div id="tab-container" class="tab-container">
<div id="general">
<!-- Sidebar big buttons -->
<div id="general" style="display: block;" class="active">
<ul class="subNav">
<li><span class="icos-images2"></span>Add Appointment</li>
<li class="activeli"><span class="icos-images2"></span>View/Edit Appointments</li>
<li><span class="icos-images2"></span>Appointments History</li>
<li><span class="icos-images2"></span>View/Edit Reminder Settings</li>
<li><span class="icos-images2"></span>Add Reminder Settings</li>
<li><span class="icos-images2"></span>View/Edit Medicine Reminder Settings</li>
<li><span class="icos-images2"></span>Add Medicine Reminder Settings</li>
</ul>
</div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
<!-- Sidebar ends -->
<!-- Content begins -->
<div id="content">
<div class="contentTop">
<span class="pageTitle"><span class="icon-screen"></span>Edit Appointment</span>
<div class="clear"></div>
</div>
<!-- Breadcrumbs line -->
<div class="breadLine">
<div class="bc">
<ul id="breadcrumbs" class="breadcrumbs">
<li>Dashboard</li>
<li>Appointments</li>
<li class="current">Edit Appointment</li>
</ul>
</div>
</div>
<!-- Main content -->
<div class="wrapper">
<div class="fluid">
<form name="formEditAppointment" id="usualValidate" class="main" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<div class="widget grid6 chartWrapper" style="width:100%;min-height:550px;">
<div class="whead"><h6>Edit Appointment Information</h6><div class="clear"></div></div>
<div class="formRow">
<div class="grid3"><label>File No:<span class="req">*</span></label></div>
<div class="grid9"><?php echo stripslashes($resultPatient[0]['fileno']);?></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Name:<span class="req">*</span></label></div>
<div class="grid9"><input type="text" class="required" name="name" id="name" value="<?php echo stripslashes($resultPatient[0]['name']);?>"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Email:</label></div>
<div class="grid9"><input type="text" class="email" name="email" id="email" value="<?php echo stripslashes($resultPatient[0]['email']);?>"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Age:</label></div>
<div class="grid9"><input type="text" class="required" name="age" id="age" value="<?php echo stripslashes($resultPatient[0]['age']);?>"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Service:<span class="req">*</span></label></div>
<div class="grid9 searchDrop"><select data-placeholder="select service..." class="select" style="width: 100%" name="id_service">
<?php if($resultUsers1 && count($resultUsers1)>0)
foreach($resultUsers1 as $user)
{?>
<option value="<?php echo $user['id_photo']?>"<?php if($user['id_photo']==$user['title']) { ?> selected="selected" <?php } ?>><?php echo $user['title'];?></option>
<?php }?>
</select></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Phone:</label></div>
<div class="grid9"><input type="text" name="phone" id="phone" value="<?php echo stripslashes($resultPatient[0]['phone']);?>"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Date:</label></div>
<div class="grid9"><input type="text" class="required datepicker" name="date" id="date" value="<?php echo date('d-m-Y',strtotime($resultPatient[0]['date']));?>"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Time:</label></div>
<div class="grid9 searchDrop">
<input id="basicExample" type="text" name="time" class="time" value="<?php echo stripslashes($resultPatient[0]['time']);?>" style="width:80px"/>
</div>
<div class="clear"></div>
</div>
<input type="hidden" value="<?php echo $id; ?>" name="id" id="id_patient"/>
<input type="hidden" value="editPatient" name="requesttype"/>
<div class="formRow">
<div class="formSubmit">
<input class="buttonM bRed" id="next1" value="Save" type="submit">
<div class="clear"></div>
</div> <div class="clear"></div>
</div>
<div class="clear"></div></div>
</form>
</div>
</div>
<!-- Main content ends -->
</div>
<!-- Content ends -->
</body>
</html>
Add Appointment.php:
<?php
include_once 'config.php';
if(isset($_POST['requesttype'])&&$_POST['requesttype'] == 'addPatient'){
$insertInfo=array();
$insertInfo['users_id_user'] = $_REQUEST['id_user'];
$insertInfo['name'] = $_REQUEST['name'];
$insertInfo['email'] = $_REQUEST['email'];
$insertInfo['age'] = $_REQUEST['age'];
$insertInfo['gender'] = $_REQUEST['act'];
$insertInfo['service_id']=$_REQUEST['id_service'];
$insertInfo['phone'] = str_replace(array('(',')',' ','-'), array('','','',''),$_REQUEST['phone']);
$insertInfo['date'] = date('d-m-Y', strtotime($_REQUEST['date']));
$insertInfo['time'] = $_REQUEST['time'];
$insertInfo['confirm_status'] = 'c';
$date=date('Y-m-d H:i:s');
$insertInfo['date_created']=$date;
$insertInfo['date_updated']=$date;
$res=$db->insert('patients', $insertInfo);
$id=$_REQUEST['id_user'];
$where="t.users_id_user='$id' AND";
$query="SELECT t.device_id,t.platforms_id_platform as id_platform FROM tokens as t WHERE $where t.device_id!=''";
$resultTokens=$db->select($query);
if($resultTokens)
{
include_once 'Gcm.php';
include_once 'Apns.php';
$deviceTokens=array();
$deviceTokens1=array();
$alert='Your appointment is confirmed on '.$insertInfo['date'].' at '.$insertInfo['time'];
foreach($resultTokens as $token)
{
if($token['id_platform']=='1'&&$token['device_id']!='')
$deviceTokens[]=$token['device_id'];
if($token['id_platform']=='2'&&$token['device_id']!='')
$deviceTokens1[]=$token['device_id'];
}
if(count($deviceTokens)>0)
{
$apns=new Apns();
$apns->apnsPush($deviceTokens,$alert);
}
if(count($deviceTokens1)>0)
{
$gcm = new GCM();
$message = array("m" => $alert);
$result = $gcm->send_notification($deviceTokens1,$message);
}
}
header("Location:appointments.php?m=a");
}
$query="SELECT * FROM users";
$resultUsers=$db->select($query);
//$query="SELECT * FROM services";
$query="select * from photos where type='service'";
$resultUsers1=$db->select($query);
include_once 'header.php';
?>
<script type="text/javascript" src="js/jquery.timepicker.js"></script>
<link rel="stylesheet" type="text/css" href="js/jquery.timepicker.css" />
<script>
$(function() {
$('#basicExample').timepicker();
});
</script>
<!-- Sidebar begins -->
<div id="sidebar">
<!-- Left Main menu begins -->
<?php include_once 'menu.php'; ?>
<!-- Left Main menu ends -->
<!-- Secondary nav -->
<div class="secNav">
<div class="secWrapper">
<!--div class="secTop">
</div-->
<!-- Tabs container -->
<div id="tab-container" class="tab-container">
<div id="general">
<!-- Sidebar big buttons -->
<div id="general" style="display: block;" class="active">
<ul class="subNav">
<li class="activeli"><span class="icos-images2"></span>Add Appointment</li>
<li><span class="icos-images2"></span>View/Add Appointments</li>
<li><span class="icos-images2"></span>Appointments History</li>
<li><span class="icos-images2"></span>View/Add Reminder Settings</li>
<li><span class="icos-images2"></span>Add Reminder Settings</li>
<li><span class="icos-images2"></span>View/Add Medicine Reminder Settings</li>
<li><span class="icos-images2"></span>Add Medicine Reminder Settings</li>
</ul>
</div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
<!-- Sidebar ends -->
<!-- Content begins -->
<div id="content">
<div class="contentTop">
<span class="pageTitle"><span class="icon-screen"></span>Add Appointment</span>
<div class="clear"></div>
</div>
<!-- Breadcrumbs line -->
<div class="breadLine">
<div class="bc">
<ul id="breadcrumbs" class="breadcrumbs">
<li>Dashboard</li>
<li>Appointments</li>
<li class="current">Add Appointment</li>
</ul>
</div>
</div>
<!-- Main content -->
<div class="wrapper">
<div class="fluid">
<form name="formAddAppointment" id="usualValidate" class="main" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<div class="widget grid6 chartWrapper" style="width:100%;min-height:680px;">
<div class="whead"><h6>Add Appointment Information</h6><div class="clear"></div></div>
<div class="formRow">
<div class="grid3"><label>File No:<span class="req">*</span></label></div>
<div class="grid9 searchDrop"><select data-placeholder="Choose a File No..." class="select" style="width: 100%" name="id_user">
<option value='0'>All</option>
<?php if($resultUsers && count($resultUsers)>0)
foreach($resultUsers as $user)
{?>
<option value="<?php echo $user['id_user']?>"><?php echo $user['fileno']?></option>
<?php }?>
</select></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Name:<span class="req">*</span></label></div>
<div class="grid9"><input type="text" class="required" name="name" id="name"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Email:</label></div>
<div class="grid9"><input type="text" class="email" name="email" id="email"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Age:</label></div>
<div class="grid9"><input type="text" class="required" name="age" id="age"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Sex:</label></div>
<div class="grid9 check"><label for="solve" class="mr20">Male:</label><input style="margin-top:5px;" type="radio" id="solve" name="act" value="m" class="required"/><label for="solve1" class="mr20">Female:</label><input style="margin-top:5px;" type="radio" id="solve1" name="act" value="f" /></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Service:<span class="req">*</span></label></div>
<div class="grid9 searchDrop"><select data-placeholder="select service..." class="select" style="width: 100%" name="id_service">
<option value='0'>All</option>
<?php if($resultUsers1 && count($resultUsers1)>0)
foreach($resultUsers1 as $user)
{?>
<option value="<?php echo $user['id_photo']?>"><?php echo $user['title']?></option>
<?php }?>
</select></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Phone:</label></div>
<div class="grid9"><input type="text" name="phone" id="phone" /></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Date:</label></div>
<div class="grid9"><input type="text" class="required datepicker" name="date" id="date" value="<?php echo date('d-m-Y',strtotime('now'));?>"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Time:</label></div>
<div class="grid9 searchDrop">
<input id="basicExample" type="text" class="time" style="width:80px" name="time"/>
</div>
<div class="clear"></div>
</div>
<input type="hidden" value="addPatient" name="requesttype"/>
<div class="formRow">
<div class="formSubmit">
<input class="buttonM bRed" id="next1" value="Save" type="submit">
<div class="clear"></div>
</div> <div class="clear"></div>
</div>
<div class="clear"></div></div>
</form>
</div>
</div>
<!-- Main content ends -->
</div>
<!-- Content ends -->
</body>
</html>
Find this code <?php if($user['id_photo']==$user['title']) { ?>. You should check the database value with the option value when you edit. Replace with <?php if($user['id_photo']==$resultPatient[0]['id_photo']) { ?> and check.

Some Database Fatal Error

I want to install php code with XAMPP. I created new database and called it s13. After that i have pasted my all codes to the folder s13.
this what I actually recieving error
Fatal error: Call to a member function __() on a non-object in C:\xampp\htdocs\s13\content\themes\default\templates_c\90f81337a2395d597b1b2483c3c3bf40f723241a.file.header.tpl.php on line 199
My config php code
<?php
define('DB_NAME', 's13')
;
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
define('DEBUGGING', true);
?>
and this what i actually recieving error code
<body page="{$page}" ub="{$userArray.Blocked}">
<!-- Common JS -->
<script>var SITE_URL = '{$SITE_URL}/';</script>
<script type="text/javascript" src="{$SITE_URL}/js/core.common.js"></script>
<!-- Common JS -->
{if $userExist}
<!-- Common [User Exist] JS -->
<script type="text/javascript" src="{$SITE_URL}/js/core.common.signedin.js"></script>
<script type="text/javascript" src="{$SITE_URL}/js/core.chat.js"></script>
<!-- Common [User Exist] JS -->
{if $userArray.Verified == "N"}
<!-- Verify Bar -->
<div class="verifyBarHolder">
<div class="verifyBar">
<div class="verifyBarContent">
<div class="right">
<span class="uiButtonText black resendEmail">{$translate->__("Resend Confirmation Email")}</span> · <span class="uiButtonText black changeEmail">{$translate->__("Change Email Address")}</span>
</div>
{$userArray.UserFirstName}, {$translate->__("go to")} <strong>{$userArray.UserEmail}</strong> {$translate->__("to complete the sign-up process")}.
</div>
</div>
</div>
<!-- Verify Bar -->
{/if}
<!-- Header -->
<div class="headerBarHolder">
<div class="headerBar {if $userArray.Verified == "N"}afterVerify{/if}">
<div class="header">
<!-- Logo -->
<div class="logo"><span>{$translate->__("Home")}</span></div>
<!-- Logo -->
<!-- Search -->
<div class="search">
<form id="searchForm" class="relative" action="{$SITE_URL}/search.php" method="get">
<span class="glass"><i></i></span>
<input class="uiInput searchInput" type="text" name="q" value="{$translate->__("Search")}" />
</form>
</div>
<!-- Search -->
<!-- Navigation -->
<div class="navigation">
<ul class="list">
<li class="item" title="{$translate->__("Home")}">
<a class="navApp homeIcon" href="{$SITE_URL}/home.php"></a>
</li>
<li class="item">
<div class="icon relative">
<div class="navApp profileIcon" id="profileIcon"></div>
<!-- Profile Menu -->
<div class="subMenu toRight navigationMenu">
<ul>
<li><a class="menuItem" href="{$SITE_URL}/{$userArray.UserName}">{$translate->__("Profile")}</a></li>
<li><a class="menuItem" href="{$SITE_URL}/settings/">{$translate->__("Settings")}</a></li>
</ul>
</div>
<!-- Profile Menu -->
</div>
</li>
<li class="item">
<div class="icon relative">
<div class="navApp messagesIcon" id="messagesIcon"><span class="counter hidden" id="msgCounter"></span></div>
<!-- Messages Menu -->
<div class="subMenu toRight navigationMenu">
<ul class="navMenu" id="liveMessages">
<li>
<div class="navMenuTitle">
<div class="right">
{$translate->__("See All")}
</div>
<strong>{$translate->__("Messages")}</strong>
</div>
</li>
</ul>
</div>
<!-- Messages Menu -->
</div>
</li>
<li class="item">
<div class="icon relative">
<div class="navApp notificationsIcon" id="notificationsIcon"><span class="counter hidden" id="notifiCounter"></span></div>
<!-- Notifications Menu -->
<div class="subMenu toRight navigationMenu">
<ul class="navMenu" id="liveNotifications">
<li>
<div class="navMenuTitle">
<div class="right">
{$translate->__("See All")}
</div>
<strong>{$translate->__("Notifications")}</strong>
</div>
</li>
</ul>
</div>
<!-- Notifications Menu -->
</div>
</li>
</ul>
</div>
<!-- Navigation -->
<!-- Sign Out -->
<div class="signOut">
<a class="navApp signoutIcon right" href="{$SITE_URL}/signout/" title="{$translate->__("Log Out")}"></a>
</div>
<!-- Sign Out -->
</div>
</div>
</div>
<!-- Header -->
{else}
<!-- Common [User Non-Exist] JS -->
<script type="text/javascript" src="{$SITE_URL}/js/core.common.unsignedin.js"></script>
<!-- Common [User Non-Exist] JS -->
<!-- Header -->
<div class="headerBarHolder userNonExist">
<div class="headerBar userNonExist">
<div class="header">
<!-- Logo -->
<div class="logo userNonExist"><span>{$translate->__("Home")}</span></div>
<!-- Logo -->
<!-- Search -->
<div class="search userNonExist">
<form id="searchForm" class="relative" action="{$SITE_URL}/search.php" method="get">
<span class="glass"><i></i></span>
<input class="uiInput searchInput" type="text" name="q" value="{$translate->__("Search")}" />
</form>
</div>
<!-- Search -->
{if $page != "signin"}
<!-- Sign In -->
<div class="signIn">
<div class="relative">
<span>{$translate->__("Have an account?")}<a class="signInBox ml5" href="{$SITE_URL}/signin/"><span>{$translate->__("Sign in")}</span></a></span>
<div id="signInMenu" class="signInMenu">
<form action="{$SITE_URL}/signin/" method="post">
<div class="inline mb10 pt10 pb10" style="width: 210px; border-bottom: 1px solid #333333;">
<div class="left pt5 mr10">
<span>{$translate->__("Sign in with")}</span>
</div>
<div class="left">
<a class="connect-facebook-vsmall" title="{$translate->__("Sign in with")} Facebook" href="{$SITE_URL}/connect/facebook/"></a> <a class="connect-twitter-vsmall" title="{$translate->__("Sign in with")} Twitter" href="{$SITE_URL}/connect/twitter/"></a>
</div>
</div>
<p class="mb10">
<label class="inputLabel" for="username_email">{$translate->__("Username or email")}:</label>
<input type="text" name="username_email" tabindex="1" />
</p>
<p class="mb10">
<label class="inputLabel" for="email">{$translate->__("Password")}:</label>
<input type="password" name="password" tabindex="2" />
</p>
<p class="mb10 pb10" style="border-bottom: 1px solid #333333;">
<input type="submit" name="submit" value="{$translate->__("Sign in")}" class="uiButton pr10 pl10" tabindex="4" />
<input type="checkbox" id="remember" name="remember" value="yes" tabindex="3"/>
<label for="remember">{$translate->__("Remember me")}</label>
</p>
<p class="mb5">{$translate->__("Forgot your password?")}</p>
<p>{$translate->__("Create a new account")}</p>
</form>
</div>
</div>
</div>
<!-- Sign In -->
{/if}
</div>
</div>
</div>
<!-- Header -->
{/if}
The error means, that at least one of variables assigned to Smarty is not an object for example maybe $translate is not an object. It is not connected directly to Database
Of course database has nothing in common with folders, so I have no idea why you wrote that you created database s13 and put all your data to s13 folder. Database and foldername where you have files on your server can be different.

PHP using sqlite3 with forms

I am new to php and sqlite and wanted to make a form that inserts everything there into the database.
This is my contact.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>G6 Mall | Contact</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
<link rel="stylesheet" href="css/layout.css" type="text/css" media="all">
<link rel="stylesheet" href="css/style.css" type="text/css" media="all">
<script type="text/javascript" src="js/jquery-1.5.2.js" ></script>
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/cufon-replace.js"></script>
<script type="text/javascript" src="js/Terminal_Dosis_300.font.js"></script>
<script type="text/javascript" src="js/atooltip.jquery.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<!--[if lt IE 9]>
<script type="text/javascript" src="js/html5.js"></script>
<style type="text/css">.bg {behavior:url("js/PIE.htc")}</style>
<![endif]-->
</head>
<body id="page6">
<div class="body1">
<div class="body2">
<div class="body3">
<div class="main">
<!-- header -->
<header>
<div class="wrapper">
<h1></h1>
<form id="search" action="#" method="post">
<div>
<input type="submit" class="submit" value="">
<input class="input" type="text" value="Site Search" onBlur="if(this.value=='') this.value='Site Search'" onFocus="if(this.value =='Site Search' ) this.value=''">
</div>
</form>
<nav>
<ul id="menu">
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Directory</li>
<li>News</li>
<li id="active" class="end">Contact</li>
</ul>
</nav>
</div>
</header>
<!-- / header-->
<!-- content -->
<section id="content">
<div class="wrapper">
<h2>General Enquiry Form</h2>
<form id="FeedbackForm" action="post.php" method="post">
<div>
<div class="wrapper"> <span>Name:</span>
<input type="text" class="input" name="NAME">
</div>
<div class="wrapper"> <span>Contact:</span>
<input type="text" class="input" name="CONTACT">
</div>
<div class="wrapper"> <span>E-mail:</span>
<input type="text" class="input" name="EMAIL">
</div>
<div class="textarea_box"> <span>Message: (50char)</span>
<textarea name="COMMENT" cols="1" rows="1"></textarea>
</div>
<input type="submit" name="update" value="update">
<!--<span> </span> Clear Send </div>-->
</form>
</div>
</section>
</div>
</div>
</div>
</div>
<div class="body4">
<div class="main">
<section id="content2">
<div class="wrapper">
<div style="text-align: center;">
<h2>Where are we located at? </h2>
<strong>Lot-6 G6 Street, Wollongong, 6666 NSW</strong>
<p><!--spacing between the headers-->
</div>
<div class="line3 wrapper">
<article class="col2">
<h2>G6 Card privileges+ </h2>
<div class="pad"> <span class="col3"> <strong>
Telephone:<br>
Email: </strong> </span>
+614 1234 6666<br>
g6card#g6.com </div>
</article>
<article class="col2">
<h2>Customer Service Centre </h2>
<div class="pad"> <span class="col3"> <strong>
Telephone:<br>
Email: </strong> </span>
+614 1234 5555<br>
custserv#g6.com </div>
</article>
<article class="col2">
<h2>Advertisement & Promotion</h2>
<div class="pad"> <span class="col3"> <strong>
Telephone:<br>
Fax No:<br>
Email: </strong> </span>
+614 1234 7777<br>
+614 1234 1212<br>
adsPromo#g6.com </div>
</article>
<article class="col2">
<h2>Leasing</h2>
<div class="pad"> <span class="col3"> <strong>
Telephone:<br>
Fax No:<br>
Email: </strong> </span>
+614 7728 8878<br>
+614 7726 8869<br>
leasing#g6.com </div>
</article></div>
</div>
</section>
</div>
</div>
<!-- / content -->
<div class="main">
<!-- footer -->
<footer>
<div class="wrapper"> <span class="left"> Copyright © G6. All Rights Reserved<br>
Design by LM-02</a><br>
</span>
<ul id="icons">
Connect with us: <br>
<li><img src="images/icon1.png" alt=""></li>
<li><img src="images/icon4.png" alt=""></li>
</ul>
</div>
<!-- {%FOOTER_LINK} -->
</footer>
<!-- / footer -->
</div>
</body>
</html>
Then i made a post.php and put this code down
<?php
$NAME = sqlite_escape_string($_POST['NAME']);
$CONTACT = sqlite_escape_string($_POST['CONTACT']);
$EMAIL = sqlite_escape_string($_POST['EMAIL']);
$COMMENT = sqlite_escape_string($_POST['COMMENT']);
class MyDB extends SQLite3
{
function __construct()
{
$this->open('final_mall_management_system.db');
}
}
$db = new MyDB();
if(!$db){
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully\n";
}
$sql =<<<EOF
INSERT INTO Enquiry (Name,Contact,Email,Comment)
VALUES ( '$NAME', '$CONTACT', '$EMAIL', '$COMMENT' );
EOF;
$ret = $db->exec($sql);
if(!$ret){
echo $db->lastErrorMsg();
} else {
echo "Records created successfully\n";
}
$db->close();
?>
When I entered the data in the form and click the submit it doesn't work I get this instead
open('final_mall_management_system.db'); } } $db = new MyDB(); if(!$db){ echo $db->lastErrorMsg(); } else { echo "Opened database successfully\n"; } $sql =<<exec($sql); if(!$ret){ echo $db->lastErrorMsg(); } else { echo "Records created successfully\n"; } $db->close(); ?>
I have no idea what I'm doing wrong. Could anyone please help me?
<section id="content">
<div class="wrapper">
<h2>General Enquiry Form</h2>
<form id="FeedbackForm" action="post.php" method="post">
<div>
<div class="wrapper"> <span>Name:</span>
<input type="text" class="input" name="NAME">
</div>
<div class="wrapper"> <span>Contact:</span>
<input type="text" class="input" name="CONTACT">
</div>
<div class="wrapper"> <span>E-mail:</span>
<input type="text" class="input" name="EMAIL">
</div>
<div class="textarea_box"> <span>Message: (50char)</span>
<textarea name="COMMENT" cols="1" rows="1"></textarea>
</div>
<input type="submit" name="update" value="update">
<!--<span> </span> Clear Send </div>-->
</form>
</div>
</section>
Is the main section of the "form" html code from the whole code (content.html) that i showed above.
Change remove EOF thing and use double quotes for your sql, I think that's the problem.
$sql ="INSERT INTO Enquiry (Name,Contact,Email,Comment)
VALUES ( '$NAME', '$CONTACT', '$EMAIL', '$COMMENT' )";
most likely you redefined constructor to SQLite3 class itself.
http://www.php.net/manual/en/language.oop5.decon.php
try changing
function __construct() {
$this->open('final_mall_management_system.db');
}
to
function __construct() {
parent::__construct();
$this->open('final_mall_management_system.db');
}

Categories