Hello. I am at beginning with php and now trying to make an ecommerce website. I know it's a bit stupid but it works until now. This site work perfect on localhost using xampp but then I transfered it to webhost, I get a lot of errors.
Code is below. I get a lot of errors on it like: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/avusproh/public_html/customer/my_account.php on line 23
First session didn't started from login. I will leave login code too. What I can do to this code so then someone login, session will start and this session will be keept. After it, login will redirect him to my_accounts (code below). Here first session didn't started so I put an else condition at the top. Now I have that error and I still get warnings like this everythere:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/avusproh/public_html/index.php:2) in /home/avusproh/public_html/index.php on line 3
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/avusproh/public_html/index.php:2) in /home/avusproh/public_html/index.php on line 3
My_Account Code:
<!DOCTYPE>
<?php
error_reporting(0);
session_start();
include("includes/db.php");
if(isset($_SESSION['customer_username'])) {
echo "<script>alert('Not')</script>";
}
else
{
echo "<script>alert('Works')</script>
}
?>
<html>
<head>
<title>MyAccount | mSocials</title>
<link href='css.css' rel='stylesheet' />
</head>
<body>
<div id='header'>
<br/>
<?php
$user = $_SESSION['customer_username'];
$credits = mysqli_query($con, "SELECT credits from customers where customer_username= '$user'");
$row = mysqli_fetch_assoc($credits);
$credit = $row["credits"];
if(isset($_SESSION['customer_username'])) {
echo "<h1>Welcome " . $_SESSION['customer_username'] . " to UserPanel. You have " . $credit . " Credits to spend on our services.</h1>";
}
?>
</div>
<div id='content'>
<?php
if(!isset($_GET['purchase_services'])){
if(!isset($_GET['my_orders'])){
if(!isset($_GET['price_list'])){
if(!isset($_GET['purchase_credits'])){
if(!isset($_GET['edit_account'])){
echo"
<div id='first'>
<a href='my_account.php?purchase_services'> <img src='images/add.png' height='200' />
</a>
<p>Add Order</p>
</div>
<div id='second'>
<a href='my_account.php?my_orders'> <img src='images/search.png' height='200' /></a>
<p>View all orders</p>
</div>
<div id='third'>
<a href='my_account.php?price_list'><img src='images/Illustration%20Of%20Dollar%20Signs.png' height='200' /></a>
<p>Price List</p>
</div>
<div id='fourth'>
<a href='my_account.php?purchase_credits'><img src='images/deposit.png' height='200' /></a>
<p>Purchase Credits</p>
</div>
<div id='fifth'>
<a href='my_account.php?edit_account'><img src='images/profile-icon.png' height='200' /></a>
<p>View/Edit your profile</p>
</div>
<div id='sixth'>
<a href='logout.php'><img src='images/300px-Crystal_Clear_action_exit.svg.png' height='200' /></a>
<p>LogOut</p>
</div>";
}
}
}
}
}
?>
<?php
if(isset($_GET['edit_account'])){
include('includes/edit_account.php');
}
if(isset($_GET['purchase_credits'])) {
include('includes/purchase_credits.php');
}
if(isset($_GET['price_list'])) {
include('includes/price_list.php');
}
if(isset($_GET['my_orders'])) {
include('includes/my_orders.php');
}
if(isset($_GET['purchase_services'])) {
include('purchase_services');
}
?>
</div>
<div id='footer'>
<br />
<br />
<a id='copyright' href='#'>Copyright © 2014 mSocials.com. All rights reserved</a>
</div>
</body>
</html>
LogIn Code:
<!DOCTYPE >
<?php
session_start();
include("includes/db.php");
?>
<html>
<head>
<meta charset="UTF-8">
<title>mSocials UserLogIn</title>
<style>
/*! normalize.css v3.0.2 | MIT License | git.io/normalize */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace, monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}
</style>
<style>
@import url(http://fonts.googleapis.com/css?family=Open+Sans);
.btn { display: inline-block; *display: inline; *zoom: 1; padding: 4px 10px 4px; margin-bottom: 0; font-size: 13px; line-height: 18px; color: #333333; text-align: center;text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); vertical-align: middle; background-color: #f5f5f5; background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6); background-image: -ms-linear-gradient(top, #ffffff, #e6e6e6); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)); background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); background-image: linear-gradient(top, #ffffff, #e6e6e6); background-repeat: repeat-x; filter: progid:dximagetransform.microsoft.gradient(startColorstr=#ffffff, endColorstr=#e6e6e6, GradientType=0); border-color: #e6e6e6 #e6e6e6 #e6e6e6; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); border: 1px solid #e6e6e6; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); cursor: pointer; *margin-left: .3em; }
.btn:hover, .btn:active, .btn.active, .btn.disabled, .btn[disabled] { background-color: #e6e6e6; }
.btn-large { padding: 9px 14px; font-size: 15px; line-height: normal; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; }
.btn:hover { color: #333333; text-decoration: none; background-color: #e6e6e6; background-position: 0 -15px; -webkit-transition: background-position 0.1s linear; -moz-transition: background-position 0.1s linear; -ms-transition: background-position 0.1s linear; -o-transition: background-position 0.1s linear; transition: background-position 0.1s linear; }
.btn-primary, .btn-primary:hover { text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); color: #ffffff; }
.btn-primary.active { color: rgba(255, 255, 255, 0.75); }
.btn-primary { background-color: #4a77d4; background-image: -moz-linear-gradient(top, #6eb6de, #4a77d4); background-image: -ms-linear-gradient(top, #6eb6de, #4a77d4); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#6eb6de), to(#4a77d4)); background-image: -webkit-linear-gradient(top, #6eb6de, #4a77d4); background-image: -o-linear-gradient(top, #6eb6de, #4a77d4); background-image: linear-gradient(top, #6eb6de, #4a77d4); background-repeat: repeat-x; filter: progid:dximagetransform.microsoft.gradient(startColorstr=#6eb6de, endColorstr=#4a77d4, GradientType=0); border: 1px solid #3762bc; text-shadow: 1px 1px 1px rgba(0,0,0,0.4); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.5); }
.btn-primary:hover, .btn-primary:active, .btn-primary.active, .btn-primary.disabled, .btn-primary[disabled] { filter: none; background-color: #4a77d4; }
.btn-block { width: 100%; display:block; }
* { -webkit-box-sizing:border-box; -moz-box-sizing:border-box; -ms-box-sizing:border-box; -o-box-sizing:border-box; box-sizing:border-box; }
html { width: 100%; height:100%; overflow:hidden; }
body {
width: 100%;
height:100%;
font-family: 'Open Sans', sans-serif;
background: #092756;
background: -moz-radial-gradient(0% 100%, ellipse cover, rgba(104,128,138,.4) 10%,rgba(138,114,76,0) 40%),-moz-linear-gradient(top, rgba(57,173,219,.25) 0%, rgba(42,60,87,.4) 100%), -moz-linear-gradient(-45deg, #670d10 0%, #092756 100%);
background: -webkit-radial-gradient(0% 100%, ellipse cover, rgba(104,128,138,.4) 10%,rgba(138,114,76,0) 40%), -webkit-linear-gradient(top, rgba(57,173,219,.25) 0%,rgba(42,60,87,.4) 100%), -webkit-linear-gradient(-45deg, #670d10 0%,#092756 100%);
background: -o-radial-gradient(0% 100%, ellipse cover, rgba(104,128,138,.4) 10%,rgba(138,114,76,0) 40%), -o-linear-gradient(top, rgba(57,173,219,.25) 0%,rgba(42,60,87,.4) 100%), -o-linear-gradient(-45deg, #670d10 0%,#092756 100%);
background: -ms-radial-gradient(0% 100%, ellipse cover, rgba(104,128,138,.4) 10%,rgba(138,114,76,0) 40%), -ms-linear-gradient(top, rgba(57,173,219,.25) 0%,rgba(42,60,87,.4) 100%), -ms-linear-gradient(-45deg, #670d10 0%,#092756 100%);
background: -webkit-radial-gradient(0% 100%, ellipse cover, rgba(104,128,138,.4) 10%,rgba(138,114,76,0) 40%), linear-gradient(to bottom, rgba(57,173,219,.25) 0%,rgba(42,60,87,.4) 100%), linear-gradient(135deg, #670d10 0%,#092756 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3E1D6D', endColorstr='#092756',GradientType=1 );
}
.login {
position: absolute;
top: 50%;
left: 50%;
margin: -150px 0 0 -150px;
width:300px;
height:300px;
}
.login h1 { color: #fff; text-shadow: 0 0 10px rgba(0,0,0,0.3); letter-spacing:1px; text-align:center; }
input {
width: 100%;
margin-bottom: 10px;
background: rgba(0,0,0,0.3);
border: none;
outline: none;
padding: 10px;
font-size: 13px;
color: #fff;
text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
border: 1px solid rgba(0,0,0,0.3);
border-radius: 4px;
box-shadow: inset 0 -5px 45px rgba(100,100,100,0.2), 0 1px 1px rgba(255,255,255,0.2);
-webkit-transition: box-shadow .5s ease;
-moz-transition: box-shadow .5s ease;
-o-transition: box-shadow .5s ease;
-ms-transition: box-shadow .5s ease;
transition: box-shadow .5s ease;
}
input:focus { box-shadow: inset 0 -5px 45px rgba(100,100,100,0.4), 0 1px 1px rgba(255,255,255,0.2); }
</style>
<script src="js/prefixfree.min.js"></script>
</head>
<body>
<div class="login">
<h1>Login</h1>
<form method="post">
<input type="text" name="u" placeholder="Username" required="required" />
<input type="password" name="p" placeholder="Password" required="required" />
<button type="submit" class="btn btn-primary btn-block btn-large" name="login">LogIn</button>
</form>
<button class="btn btn-primary btn-block btn-large" onclick="window.location='index.php'">Back to Home Page </button>
</div>
<script src="js/index.js"></script>
</body>
</html>
<?php
if (isset($_POST['login'])) {
$c_user = $_POST['u'];
$c_pass = $_POST['p'];
$set_c = "select * from customers where customer_password = '$c_pass' AND customer_username = '$c_user'";
$run_c = mysqli_query($con, $set_c);
$check_customer = mysqli_num_rows($run_c);
if ($check_customer==0) {
echo "<script>alert('Username or Password is incorrect.')</script>";
exit();
}
if ($check_customer==1) {
$_SESSION['customer_username']=$c_user;
echo "<script>alert('Successfull LogIn')</script>";
echo "<script>window.open('customer/my_account.php','_self')</script>";
}
}
?>
Thanks a lot.