once user login, we are displaying all the information of user in profile/account page. please check code quality , security & Performance.
<?php
include 'home.php';
// session_start();
require_once 'class.user.php';
$user_home = new USER();
if (!$user_home->is_logged_in()) {
header("Location: index.php");
die();
}
?>
<?php
if (isset($_POST['submit'])) {
// new data
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$street_address = $_POST['street_address'];
$street_address_2 = trim($_POST['street_address_2']);
$city = trim($_POST['city']);
$state = trim($_POST['state']);
$zip_code = trim($_POST['zip_code']);
$country = trim($_POST['country']);
$sold_by = trim($_POST['sold_by']);
$portfolio = trim($_POST['portfolio']);
$paypal_email_id = trim($_POST['paypal_email_id']);
$account_holder_name = trim($_POST['account_holder_name']);
$account_number = trim($_POST['account_number']);
$branch_name = trim($_POST['branch_name']);
$bank_name = trim($_POST['bank_name']);
$ifsc_code = trim($_POST['ifsc_code']);
$tax = trim($_POST['tax']);
$photo = trim($_POST['photo']);
// $uid = (isset($_GET['userID']) ? intval($_GET['userID']) : -1);
$uid = (isset($_SESSION['userSession']) ? intval($_SESSION['userSession']) : 0);
// query
if ($uid > 0) {
$user_home->update($name, $email, $phone, $street_address, $street_address_2, $city, $state, $zip_code, $country, $sold_by,
$portfolio, $paypal_email_id, $account_holder_name, $account_number, $branch_name, $bank_name, $ifsc_code, $tax, $uid);
if($_FILES['photo'])
$user_home->add_photo($_FILES['photo']);
}
}
$stmt = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
$stmt->execute(array(":uid" => $_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
/* php codde end*/
?>
<!DOCTYPE html>
<html class="no-js">
<h4> Welcome to profile page</h4>
<head>
<title><?php echo $row['email']; ?></title>
<a href="user.php?<?php print($userRow['name']); ?>"></a> <title> <?php echo $row['name']; ?> Profile page </title>
<!-- Bootstrap -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
<link href="assets/styles.css" rel="stylesheet" media="screen">
<link href="assets/style.css" rel="stylesheet" media="screen">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<body>
<form action="profile1.php" method="POST">
<h3 class = "h3">Personal details</h3>
Name :
<?php echo $row['name'] ?> <br/>
Email :
<?php echo $row['email'] ?> <br>
Sold by :
<?php echo $row['sold_by'] ?> <br/>
Portfolio :
<?php echo $row['portfolio'] ?> <br/>
<a class = "change1" href="fpass1.php">Click here to Change Password </a>
</form>
<a href="profile1.php">
<button class="pedit" name="submit">Edit</button>
</a>
<form action="profile1.php" method="POST">
<h3 class = "h3">ADDRESS</h3>
Phone :
<?php echo $row['phone'] ?> <br>
street address :
<?php echo $row['street_address'] ?> <br>
street address 2 :
<?php echo $row['street_address_2'] ?> <br>
city :
<?php echo $row['city'] ?> <br>
state :
<?php echo $row['state'] ?> <br>
country :
<?php echo $row['country'] ?> <br>
zip :
<?php echo $row['zip_code'] ?> <br>
</form>
<a href="profile1.php">
<button class="pedit" name="submit">Edit</button>
</a>
<form action="profile1.php" method="POST">
<h3 class = "h3">Payment details</h3>
Paypal email id :
<?php echo $row['paypal_email_id'] ?> <br/>
<h4> Bank Details [ Wiretransfer ] </h4>
account holder name :
<?php echo $row['account_holder_name'] ?> <br/>
account number :
<?php echo $row['account_number'] ?> <br/>
branch name :
<?php echo $row['branch_name'] ?> <br/>
bank name :
<?php echo $row['bank_name'] ?> <br/>
ifsc code :
<?php echo $row['ifsc_code'] ?> <br/>
</form>
<a href="profile1.php">
<button class="pedit" name="submit">Edit</button>
</a>
<form action="profile1.php" method="POST">
<h3 class = "h3">Other information</h3>
Tax id scan copy :
<?php if(file_exists($user_home->get_photo())): ?>
<img src="<?php echo $user_home->get_photo_url() ?>" class="avatar" />
<?php endif; ?>
<input id="sub" type="submit" name="submit" value="Save" style="display:none"/>
</form>
<a href="profile1.php">
<button class="pedit" name="submit">Edit</button>
</a>
</body>
</html>
$user_home
defined? This might be pertinent code to include in this review as, in looking at how it is being used, I think there may be some questionable design decisions within that class. \$\endgroup\$