Ok, i had some problems which i was going to post, but i solved them. But now, when i search something. i get a uid error.
Your search for Crayz returned 2 results
Notice: Undefined index: uid in C:\xampp\htdocs\GameCrayz\Search\index.php on line 55
Profile.php
<?php
include('core/init.inc.php');
$user_info = fetch_user_info($_GET['uid']);
?>
<?php
mysql_connect("localhost","root","Notimportant:P");
mysql_select_db("commentbox");
$name=strip_tags(@$_POST['name']);
$comment=strip_tags(@$_POST['comment']);
$submit=@$_POST['submit'];
$dbLink = mysql_connect("localhost", "root", "Notimportant:P");
mysql_query("SET character_set_client=utf8", $dbLink);
mysql_query("SET character_set_connection=utf8", $dbLink);
if($submit)
{
if($name&&$comment)
{
$insert=mysql_query("INSERT INTO commenttable (name,comment) VALUES ('$name','$comment') ");
}
else
{
echo "Please fill in <b>all</b> the fields.";
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
div.ex
{
width:220px;
padding:10px;
border:5px solid gray;
margin:0px;
}
</style>
<title><?php echo $user_info['username']; ?>'s Profile - GameCrayz</title>
</head>
<body>
<div>
<?php
if ($user_info === false){
echo 'That user does not exist.';
}else{
?>
<h1><?php echo $user_info['firstname']; ?> <?php echo $user_info['lastname']; ?></h1>
<p>Username: <?php echo $user_info['username']; ?></p>
<p>Gender: <?php echo ($user_info['gender'] ==1) ? 'Male' : 'Female'; ?></p>
<p>Email: <?php echo $user_info['email']; ?></p>
<p>Location: <?php echo $user_info['location']; ?></p>
<p>About me:<br><?php echo $user_info['about']; ?></p>
<a href='edit_profile.php'>Edit profile</a>
<?php
}
?>
</div>
<div class="ex">
<center>
<form action="" method="POST">
<table>
<tr><td>Name: <br><input type="text" name="name" placeholder='Enter your name...' style="width:150px;height:50px;font-family:cursive;border:double 12px #6DB72C;"/></td></tr>
<tr><td colspan="2">Comment: </td></tr>
<tr><td colspan="5"><textarea name="comment" rows="5" cols="50" style="width:200px;height:100px;font-family:cursive;border:double 12px #6DB72C;" placeholder='Enter a comment...'></textarea></td></tr>
<tr><td colspan="2"><input type="submit" name="submit" value='Comment'></td></tr>
</table>
</form>
<?php
$dbLink = mysql_connect("localhost", "root", "Notimportant:P");
mysql_query("SET character_set_results=utf8", $dbLink);
mb_language('uni');
mb_internal_encoding('UTF-8');
$getquery=mysql_query("SELECT * FROM commenttable ORDER BY id DESC");
while($rows=mysql_fetch_assoc($getquery))
{
$id=$rows['id'];
$name=$rows['name'];
$comment=$rows['comment'];
echo $name . ':<br/>' . '</br>' . $comment . '' . '<br/>' . '<hr size="1"/>'
;}
?>
</div>
</body>
</html>
User.inc.php
<?php
//fetches all of the users from the table
function fetch_users(){
$result = mysql_query('SELECT `ID` AS `id`, `Username` AS `username` FROM `users`');
$users = array();
while (($row = mysql_fetch_assoc($result)) !== false){
$users[] = $row;
}
return $users;
}
//fetches profile info for the given user
function fetch_user_info($uid){
$uid = (int)$uid;
$sql = "SELECT
`Username` AS `username`,
`user_firstname` AS `firstname`,
`user_lastname` AS `lastname`,
`user_email` AS `email`,
`user_about` AS `about`,
`user_location` AS `location`,
`user_gender` AS `gender`
FROM `users`
WHERE `ID` = {$uid}";
$result = mysql_query($sql);
return mysql_fetch_assoc($result);
}
//updates the current users profile info.
function set_profile_info($email, $about, $location){
$email = mysql_real_escape_string(htmlentities($email));
$about = mysql_real_escape_string(nl2br(htmlentities($about)));
$location = mysql_real_escape_string(htmlentities($location));
$sql = "UPDATE `users` SET
`user_email` = '{$email}',
`user_about` = '{$about}',
`user_location` = '{$location}'
WHERE `user_id` = {$_SESSION['uid']}";
mysql_query($sql);
}
?>
Index.php(search)
<?php
include 'func.inc.php';
?>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
var message="Function Disabled!";
///////////////////////////////////
function clickIE() {if (document.all) {alert(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {alert(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</script>
<title>Search</title>
<body>
<span style="color:#FFFFFF">
<h2>Search</h2>
<form action="" method="POST">
<p>
<input type="text" name="keywords" /> <input type="submit" value="Search" />
</p>
</form>
<?php
if (isset($_POST['keywords'])) {
$suffix = "";
$keywords = mysql_real_escape_string(htmlentities(trim($_POST['keywords'])));
$errors = array();
if (empty($keywords)) {
$errors[] = 'Please enter a search term.';
} else if (strlen($keywords)<3) {
$errors[] = 'Your search term must be <b>three</b> or <b>more</b> characters.';
} else if (search_results($keywords) === false) {
$errors[] = 'Your search for '.$keywords.' returned no results.';
}
if (empty($errors)) {
$results = search_results($keywords);
$results_num = count($results);
$suffix = ($results_num !=1) ? 's' : '';
echo '<p>Your search for <strong>', $keywords, '</strong> returned <strong>', $results_num,'</strong> result', $suffix, '</p>';
foreach($results as $result) {
echo "<p> <strong>ID: </strong>". $result['ID']. "<br> <a href='../Profiles/profile.php?uid=" .$result['uid']. "' target=_blank>" .$result['Username']. "</a><strong> <br>Fullname: </strong>".$result['user_firstname']." ".$result['user_lastname']."<br><strong>About: </strong>". $result['user_about']. "</br></p>";
}
} else {
foreach($errors as $error) {
echo $error, '</br>';
}
}
}
?>
</body>
</html>