Login.php
<?php
session_start();
require("Register.php");
if(isset($_POST['loginButton'])){
try {
$email = $_POST['email'];
$password = $_POST['password'];
$query = $conn->prepare("SELECT * FROM Users WHERE Email = '$email' AND password = '$password'");
$query->execute();
if($query->rowCount() > 0 ) {
$_SESSION['user'] = $email;
header("location: ../html/myAccount.html");
}
else {
echo "Email not found!";
}
}
catch (PDOException $e){
echo $e->getMessage();
}
}
?>
HTML page
<?php
session_start();
echo $_SESSION['user'];
?>
<!DOCTYPE html>
<HTML>
<HEAD>
<title>BMA.WALLET</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/page-style.css">
<link rel="stylesheet" type="text/css" href="../css/account-style.css">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic,800,800italic' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,100,300,100italic,300italic,400italic,500,500italic,700,700italic,900,900italic&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="shortcut icon" href="../img/wallet.png"/>
</HEAD>
<BODY>
<div id="wrapper">
<div id="HEADER">
<h1><span>BMA.</span>WALLET</h1>
<div class="motto">Cu noi știi unde ți-au zburat banii!</div>
<div class="main-menu">
<ul>
<li><img src="../img/facilities.png" width="40" alt="logout icon" title="Facilități"></li>
<li><img src="../img/report.png" width="40" alt="logout icon" title="Rapoartele tale"></li>
<li><img src="../img/group.png" width="40" alt="logout icon" title="Grupurile tale"></li>
<li><img src="../img/settings.png" width="40" alt="settings icon" title="Setările tale"></li>
<li><img src="../img/iconLogout.png" width="40" alt="logout icon" title="Deconectează-te!"></li>
</ul>
</div>
</div>
<div class="center" id="CONTENT">
<div class="personal-reports">
<h1>Contul personal - rapoarte</h1>
<h2>Statistică periodică: Venituri și Cheltuieli </h2>
I am building for my project a user management system and I want to show after log in the user's profile. After I press login I should be redirected to the html page. This works but I don't know how to print in the HTML page the value of $_SESSION, it doesn't matter where or how I just want to test it so I can see if it works and I get the $SESSION value. I found no solution to this so if you can help me I would really appreciate.
You have stored your email in the session variable:
$_SESSION['user'] = $email;
So, in your other HTML page, you simply need to echo this:
// myAccount.html
<?php echo "Logged in user: ".$_SESSION['user']; ?>
Related
I have an "uploads" folder that according to the database with php and mysql shows some videos, the problem is that in localhost it works, but when I insert the files in the file manager of the host (000webhost), the host cannot recognize the path "uploads", this is full code, the problem is in the video src at the end of the code.
<?php
require_once("config.php");
$result=' ';
$cerca=$_POST["cerca"];
$sql = "SELECT * FROM artisti WHERE nome like '%".$cerca."%'";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
//echo "<h1>Artisti trovato</h1>";
while ($row = $result->fetch_assoc()) {
$ID=$row["ID"];
$nome=$row["nome"];
$link=$row["link"];
$album=$row["album"];
//echo "<h2>ID: "."$ID"."</h2>";
//echo "nome: "."$nome"."<br>";
}
}
else {
echo "nessun artista trovato";
$conn->close();
exit;
}
?>
<!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.0">
<title>Utopia-Playlist</title>
<!--Reset css per ogni broswer-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css" integrity="sha512-NmLkDIU1C/C88wi324HBc+S2kLhi08PN5GDeUVVVC/BVt/9Izdsc9SVeVfA1UZbY3sHUlDSyRXhCzHfr6hmPPw==" crossorigin="anonymous" />
<!--Script scroll-->
<script src="https://unpkg.com/scrollreveal#4.0.0/dist/scrollreveal.min.js"></script>
<!--Icone-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" />
<!--Icona tab di google-->
<link rel="icon" href="Fulmine viola bianco.png">
<link rel="stylesheet" href="hero.css">
<link rel="stylesheet" href="nav.css">
<link rel="stylesheet" href="playlist1.css">
<style>
#import url('https://fonts.googleapis.com/css2?family=Overpass&display=swap');
</style>
</head>
<body>
<!--NavBar-->
<header class="he">
<h1 class="developers">Utopia Playlist</h1>
<nav>
<div class="listanav">
<li class="icon">Home</li>
<li>Playlist <i class="fas fa-caret-down"></i>
<ul class="submenu">
<li>Consigli</li>
<li>
Consigli-DV
</li>
<li> Top 50</li>
</ul>
</li>
<li>Contattaci</li>
</div>
</div>
</nav>
<button type="button" class="accedi">Accedi</button>
</header>
<!--Hero--> <!-- class="btn" -->
<div class="hero">
<div class="hero-cn scroll">
<p class="intro-text">ASCOLTA I NOSTRI CONSIGLI!</p>
<?php echo "<h1 class=grande-text>"."$nome"."</h1>"?>
<?php echo "<a class=btn href=$album>Scopri di più</a>" ?>
</div>
<video autoplay muted loop class="vd">
<source src="uploads/<?php echo $link?>" type="video/mp4" >
</video>
</div>
maybe there are some that you should check again:
The $link variable hasn't gotten the value it got
Placement of folders is not the same right
Check the connection whether it is connected to the hosting database or not
I am working on building a site, but right now it has several images that I don't have actual images for yet. As this site has thousands of images or places where images should be, I don't want to have to manually change each of them and then change them again when I find the correct image. Is there a way to create a function that will look for the missing images and replace them with a specified image until the correct image is found?
Update: Since I am still a bit confused as to where to even place this function, I am going to add the code for one of the pages that I need this for then maybe someone can help me figure out how to place it.
Here is the code for one of the pages:
<?php
require_once('dbconnection.php');
mysqli_select_db($conn, $dbname);
$query_master = "SELECT DISTINCT * FROM `master_list` INNER JOIN types_join ON master_list.join_id=types_join.join_id WHERE `type_id` = 171 ORDER BY `item_id`";
$master = mysqli_query($conn, $query_master) or die(mysqli_error());
$row_master = mysqli_fetch_assoc($master);
$totalrows_master = mysqli_num_rows($master);
?>
<!doctype html>
<html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flower Trees</title>
<link href="/css/styles.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" type="image/png" href="img/favicon.png">
</head>
<body>
<div class="wrapper">
<a id="top"></a>
<?php require_once('header.php'); ?>
<?php require_once('nav.php'); ?>
<div class="category"><h2>Flower Trees</h2></div>
<div class="display">
<?php do { ?>
<ul>
<li><a href="details.php?recordID=<?php echo $row_master['master_id']; ?>"><img class="thumb" src="img/<?php echo $row_master['img']; ?>"/>
<br />
<span class="name"><?php echo $row_master['name']; ?></span></a></li>
</ul>
<?php } while ($row_master = mysqli_fetch_assoc($master)); ?>
<!-- end .display --></div>
<?php
mysqli_free_result($master);
?>
<?php require_once('footer.php'); ?>
<!-- end .wrapper --></div>
<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>
</body>
</html>
Since this is as simple as a foreach loop, and not tons of images scattered across your webpage, you can use something like:
$image = file_exists('img/' . $row_master['img']) ? 'img/' . $row_master['img'] : 'placeholder.png';
Full code:
<?php
require_once('dbconnection.php');
mysqli_select_db($conn, $dbname);
$query_master = "SELECT DISTINCT * FROM `master_list` INNER JOIN types_join ON master_list.join_id=types_join.join_id WHERE `type_id` = 171 ORDER BY `item_id`";
$master = mysqli_query($conn, $query_master) or die(mysqli_error());
$row_master = mysqli_fetch_assoc($master);
$totalrows_master = mysqli_num_rows($master);
?>
<!doctype html>
<html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flower Trees</title>
<link href="/css/styles.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" type="image/png" href="img/favicon.png">
</head>
<body>
<div class="wrapper">
<a id="top"></a>
<?php require_once('header.php'); ?>
<?php require_once('nav.php'); ?>
<div class="category"><h2>Flower Trees</h2></div>
<div class="display">
<?php do {
$image = file_exists('img/' . $row_master['img']) ? 'img/' . $row_master['img'] : 'placeholder.png';
?>
<ul>
<li><a href="details.php?recordID=<?php echo $row_master['master_id']; ?>"><img class="thumb" src="<?php echo $image; ?>"/>
<br />
<span class="name"><?php echo $row_master['name']; ?></span></a></li>
</ul>
<?php } while ($row_master = mysqli_fetch_assoc($master)); ?>
<!-- end .display --></div>
<?php
mysqli_free_result($master);
?>
<?php require_once('footer.php'); ?>
<!-- end .wrapper --></div>
<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>
</body>
</html>
I don't want to have to manually change each of them and then change them again when I find the correct image. Is there a way to create a function that will look for the missing images and replace them with a specified image until the correct image is found?
Such a function might be written as:
function im($imgName) {
$pathToImgs = "images/";
if (file_exists( $pathToImgs . $imgName )) {
echo $pathToImgs . $imgName;
}
else {
echo $pathToImgs . "placeholder.jpg";
}
}
Then in your html:
<img src="<?php im("product1.jpg"); ?>">
<img src="<?php im("product2.jpg"); ?>">
<img src="<?php im("product3.jpg"); ?>">
As a start.
***Edit 1:
Given your code where it says:
<img class="thumb" src="img/<?php echo $row_master['img']; ?>"/>
You might modify it with a conditional that inserts the placeholder image in the event that the target image simply doesn't exist, yet.
<img class="thumb" src="<?php
if (file_exists("img/" . $row_master['img'])) {
echo "img/" . $row_master['img'];
}
else {
echo 'img/placeholder.jpg';
}
?>">
You could reuse this functionality by turning the conditional into a php function, so described as a starter above.
Using jQuery, you can accomplish something easy enough using a global $('img') handler when errors occur. Simply swap them out with your placeholder image afterwards.
$('img').on('error', function() {
const oldSrc = encodeURIComponent($(this).attr('src'));
$(this).attr('src', `https://via.placeholder.com/300/000000/FFFFFF/?text=${oldSrc}`);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<img src="imagethatdoesntexist.jpg"><br />
<img src="anotherimage.jpg">
Here I use placeholder.com (A convenient site for placeholder images such as this), and inject the old image source into the query string, which the site will render in the image itself.
The form contents are sent to my email but HTML and CSS code is not recognised on the email. Only plain text is outputted.
Below is my controller
public function registration() {
$email = $this->input->post('email');
$domain = $this->input->post('domain_name');
$passw = $this->input->post('passw');
$name = $this->input->post('name');
$skype = $this->input->post('skype');
// $package = $this->input->post('package');
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'xxxx.com',
'smtp_port' => 25,
'smtp_user' => 'xxx#xxxxxx.com',
'smtp_pass' => 'xxxxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('xxx#xxxxxx.com', 'welcome');
$this->email->to('xxxxx#xxxxxxxx.com');
$this->email->subject('registration');
$body = $this->load->view('dns/template', TRUE);
$this->email->message($body, TRUE);
$this->email->send();
$data['message'] = 'Submitted Sucessfullly';
$data['emails'] = $this->Dns_model->emails($domain);
$this->load->view('dns/sucessful', $data);
}
Below is my view saved as template.php
My view (template)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<html> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Registration</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/bootstrap.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/bootstrap-responsive.min.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/main.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/style.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/AdminLTE.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/sl-slide.css">
<script src="<?php echo base_url()?>/assets/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="<?php echo base_url()?>/images/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="<?php echo base_url()?>/images/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php echo base_url()?>/images/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="i<?php echo base_url()?>/mages/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="<?php echo base_url()?>/images/ico/apple-touch-icon-57-precomposed.png">
</head>
<body id="con" onLoad="generate();">
<div id="fb-root"></div>
<div class="container">
<section class="main-info">
<br>
<section id="recent-works3">
<section id="pricing-table">
<div class="row-fluid center clearfix">
<div class="span3">
</div>
<div class="span6">
<ul class="plan plan3">
<li class="plan-name">
<span class="lead3">Emails to be setup</span>
</li>
</ul>
<table class="table">
<thead>
<tr>
<th>Email</th>
<th>Password</th>
</tr>
</thead>
<tbody>
<tr class="info">
<td>info#test.com</td>
<td>terfwws6w</td>
</tr>
</tbody>
</table>
<ul class="plan plan3">
<li class="plan-action">
Registration website
</li>
</ul>
</div>
<div class="span3">
</div>
</div>
</section>
</section>
</section>
</div>
</div>
<script src="<?php echo base_url()?>/assets/js/vendor/jquery-1.9.1.min.js"> </script>
<script src="<?php echo base_url()?>/assets/js/vendor/bootstrap.min.js"></script>
<script src="<?php echo base_url()?>/assets/js/main.js"></script>
<script src="<?php echo base_url()?>/assets/js/jquery.ba-cond.min.js"></script>
</body>
</html>
I hope you are not using Parser library for email template, so bellow is my Answer by considering the above Condition.
You have problem with your template, means the Html code you wrote there, they have mismatched tag or some tag used in Wrong place. So you have to check that first.
If still you are not able to find out the problem then you just create a template using bellow code and You will see that the mail not more in normal text..
Nice, You nailed it...
NOTE: Don't use or etc tag and Also Use <table> instead of <div>
I am trying to get echo $userRow['student_firstname']; to pass into the html so I can use it as a automatic way to change displaying the users first name & logout with register & login. The first echo $userRow['student_firstname']; does work, however the second does not. The idea would be able to get the second to work, so I can remove the first. If there isn't a session then it displays the login & register.
<?php
session_start();
include_once 'dbconnect_new.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimal-ui">
<link href="favicon.png" type="image/x-icon" rel="shortcut icon">
<link href="assets/css/master.css" rel="stylesheet">
<script src="assets/plugins/jquery/jquery-1.11.3.min.js"></script>
</head>
<?php if(isset($_SESSION['user'])) {
// error_reporting(E_ALL ^ E_DEPRECATED);
$res=mysql_query("SELECT * FROM studentdata WHERE student_id=".$_SESSION['user']);
if ($res === FALSE){
die(mysql_error());
}
while($userRow=mysql_fetch_array($res))
{
echo $userRow['student_firstname'];
}
?>
<li class="dropdown">
<a href="">
<?php echo $userRow['student_firstname'];?><span class="nav-subtitle">Account</span></a</li>
<li>Logout<span class="nav-subtitle">Goodbye</span></li>
<?php } else { ?>
<li>Register<span class="nav-subtitle">for Students</span></li>
<li>Login<span class="nav-subtitle">for Students</span></li>
<?php } ?>
</html>
Check this link out http://php.net/manual/en/function.mysql-fetch-array.php,
Tip: USE mysqli/pdo as mysql is deprecated.
<?php
session_start();
include_once 'dbconnect_new.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimal-ui">
<link href="favicon.png" type="image/x-icon" rel="shortcut icon">
<link href="assets/css/master.css" rel="stylesheet">
<script src="assets/plugins/jquery/jquery-1.11.3.min.js"></script>
</head>
<?php
if (isset($_SESSION['user'])) {
// error_reporting(E_ALL ^ E_DEPRECATED);
$res = mysql_query("SELECT * FROM studentdata WHERE student_id=" . $_SESSION['user']);
if ($res === FALSE) {//IF QUERY RETURNS NULL
die(mysql_error());
} else {
$userRow = mysql_fetch_array($res, MYSQL_ASSOC); //DATA IN ARRAY TYPE
//IF BELOW DOES NOT WORK USE print_r(); to check the structure of array !
?>
<li class="dropdown">
<?php echo $userRow['student_firstname']; //ACCESS DATA THROUGH ITS INDEX ?><span class="nav-subtitle">Account</span>
</li>
<li>
Logout<span class="nav-subtitle">Goodbye</span>
</li>
<?php
}
} else {
?>
<li>Register<span class = "nav-subtitle">for Students</span></li>
<li>Login<span class = "nav-subtitle">for Students</span></li>
<?php } ?>
</html>
I Hope this works !
I am creating a profile page that include a profile pic, a username, title and a list of friends for the profile owner.
I used .htaccess to allow users to write in the URL, just the name of other users without putting a ? to get access to profile page.
But the problem is that if I wrote the name in the URL it works, but if I put profile .php or I press profile it displays the basic page which means that without any information related to this profile owner like a new page
How to fix this problem?
profile.php
session_start();
require_once('include/connect.php');
$login = ($_SESSION['login']);
$userid = ($_SESSION['user_id']);
$login_user = ($_SESSION['username']);
$fname = ($_SESSION['first_name']);
$lname = ($_SESSION['last_name']);
ob_start();
$username = "";
$interactionBox = "";
if(isset($_GET['u'])) {
$username = mysql_real_escape_string($_GET['u']);
if(ctype_alnum($username)) {
//check ser exists
$check = mysql_query("SELECT user_name, first_name FROM user WHERE user_name = '$username'");
if(mysql_num_rows($check) == 1) {
$get = mysql_fetch_assoc($check);
$username = $get['user_name'];
$fname = $get['first_name'];
var_dump($username);
var_dump($login_user);
} else {
echo "<meta http-equiv=\"refresh\" content=\"0; url=http://localhost/lam-el-chamel/index.php\">";
exit();
}
}
}
?>
<?php
//check if the logued in user is diffrenet from the url username
if($username != $login_user) {
$interactionBox='<div class = "InteractionLinksDiv">
Add as Friend
</div>';
} else { //check if the logued in user is equal to the url username
$interactionBox='<div style="display:inline; border:#CCC 1px solid; padding:5px; background-color:#E4E4E4; color:#999; font-size:14px;">
Others Can Add You.
</div>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Lam_El_Chamel</title>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Abel|Satisfy' rel='stylesheet' type='text/css' />
<link href="default.css" rel="stylesheet" type="text/css" media="all" />
<!--[if IE 6]>
<link href="default_ie6.css" rel="stylesheet" type="text/css" />
<![endif]-->
<script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</script>
<script language="javascript" type="text/javascript">
//jquery function for toggeling member interaction container
function toggleInteractContainers(x) {
if($('#'+x).is(":hidden")){
$('#'+x).slideDown(200);
} else {
$('#'+x).hide();
}
}
//function to add friend recive 2 arguments
function addAsFriend(a,b) {
//alert("Member with id:" + a + "request friendship with the memeber with id:" + b);
var url = "script_for_profile/request_as_friend.php";
$("#add_friend").text("please wait...").show();
$.post(url,{request:"requestFreindship",mem1:a,mem2:b},function(data){
$("#add_friend").html(data).show().fadeOut(12000);
});
}
</script>
</head>
<body>
<?php require_once('header.php');?>
<div id="wrapper">
<div id="page-wrapper">
<div id="page">
<div id="wide-content">
<?php
$check_pic = mysql_query("SELECT profile_pic FROM user WHERE user_name= '$username'")or die(mysql_error());
$get_pic_row = mysql_fetch_assoc($check_pic);
$profile_pic_db = $get_pic_row['profile_pic'];
if($profile_pic_db == "") {
$profile_pic = "images/default_img.jpg".$profile_pic_db;
}
else {
$profile_pic = "userdata/profile_pics/".$profile_pic_db;
}
?>
<img src="<?php echo $profile_pic; ?>" height="150" width="196" alt="<?php echo $username; ?>'s profile" title="<?php echo $username; ?>'s profile" />
<br />
<div class="textHeader"><?php echo $username; ?></div>
<?php echo $interactionBox; ?>
<div class="interactContainers" id="add_friend">
<div align="right">Cancel</div>
Add <?php echo $username ?> as Friend?
Yes
</div>
<div class="interactContainers" id="friend_requests" style="background-color:#FFF ; height:240px; overflow:auto;">
<h3>The Following People want to be friends</h3>
</div>
<div class="profileLeftSideContent">Introduce YourSelf....<br />
<?php
$about_query = mysql_query("SELECT interest FROM user WHERE user_name = '$username'")or die(mysql_error());
$get_result = mysql_fetch_assoc($about_query);
$about_the_user = $get_result['interest'];
echo $about_the_user;
?>
.htaccess
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?u=$1 [L]
Your current RewriteRule will rewrite a request to /profile.php to /profile.php?u=profile.php
You should define a prefix or sufix to detect URLs that should be rewritten. For example
RewriteRule ^profile/([a-zA-Z0-9_-]+)$ profile.php?u=$1 [L]
Then you would be able to access to profile pages via /profile/UserName and calling /profile.php would still work.