7 Replies - 966 Views - Last Post: 20 October 2009 - 03:17 AM Rate Topic: -----

#1 Ghost rider  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 158
  • Joined: 29-October 08

How an user can access particular contents in application

Posted 12 October 2009 - 04:53 AM

The script below access tab7.php after any user login. I would like to know!

1- How it can be done when user-1 login access his contents(photos,contacts,etc) in tab7.php. But user-2 and other can't access content of user-1 except if they're friends.

example: facebook or internet baking.
Thank in advance



index.php
<?php
	ob_start();
	$conn = mysql_connect("localhost","root", "");
	mysql_select_db("mycontinent", $conn);

	//IF SUBMIT BUTTON PRESSED
	if(isset($_POST['signin'])) 
	{
	   	if(!$_POST['username']) die("Error: You must enter your email before logging in.");
	   	if(!$_POST['password']) die("Error: You must enter your password before logging in.");
		
	   	$username = $_POST['username'];
		$password = md5($_POST['password']);
			
		$sql = "SELECT * FROM `login` WHERE username = '$username' AND user_password = '$password'";
		$result = mysql_query($sql, $conn);
		$q = mysql_fetch_array($result);
			if(!$q)
			{
			echo <<< form
			<form action="index.php" method="post">
			<button type="submit"  style="background-color:blue;">
			<p style="font-size:120%" style="color:white">Click to try again</p></button>
			</form>

form;
			//die("Login Failure: An error occured, please verify your email and password are correct.");
			}
			else $_SESSION[logged_in]=1;		
	header("Location: tabs7.php");
	}
	
	else
	{
?>
		<body BGCOLOR="white">
		<center><img src="image1/MycontinetLogo1.gif"></center>
		
		<br>
		<form action="reg1.php" GET="post">
		  <td> <p style="color:">You can broadcast  your news and toughts from Africa to around world.<br>
			   Uploading  videos, pictures and makes friends with others Africans <br>who are around the World. Also the Africans
			   who are outside the Africa<br> they can uploading the videos and pictures to show home the the real life<br> in Europe,America etc.<br>

			  <p></p>
			<table border="1" width="500">
			<tr>
				
				<td><p style="color:blue"><b>Countries</b><br/>
				 			<a href="AfricaMap.php"><img src="image1/Copy of Calcadao.JPG" width="180" height="140"></a></td>
			
				<td><p style="color:blue"><b>Bakong Gentleman(Fashion)</b></br/>
					 <a href="BakongGent.php"><img src="image1/Hector.JPG" width="200" height="150"></a></td>				

				<td><p style="color:blue"><b>Business</b><br/>
					<a href="AfricanBus.php"><img src="image1/AfricaBusines.gif" width="180" height="140"></a></td>

				<td><p style="color:blue"><b>Sport & Music</b><br/>
					<a href="Sport&Music.php"><img src="image1/puma_africa_cd.JPG" width="180" height="140"></a></td>

				<td><p style="color:blue"><b>Immigration</b><br/>
					  <a href="immigration.php"><img src="image1/immgration1.jpg" width="180" height="140"></a></td>

				<td><p style="color:blue"><b>User Space</b><br/>
					<a href="UserSpace.php"><img src="image1/noki-africa.bmp" width="180" height="140"></a></td>

				<td><p style="color:blue"><b>Education & Your News</b><br/>
					<a href="Education&News.php"><img src="image1/online_20journalism_20copy_1.jpg" width="180" height="140"></a></td>
			
			
			</tr>
		   </table>
			
			
			<br>		 
			  <input type=submit name="signing" value="Create Acount" style="background-color:blue;" style="color:white"></td>
   		</form>
   		
		   
			   <table align=right border="0">
			<form name="login" method="post" action="index.php">
				<tr>
		 	 		<td><p style="color:Gray"><b>Email</b>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
		 	 		<input type="text" id="username" name="username"></p></td>
				</tr>
				<tr>
					  <td><p style="color:gray"><b>Password</b>&nbsp&nbsp&nbsp&nbsp
					  <input type="password" id="password" name="password"></p></td>
				</tr>
		
				<tr>
					  <td><br><input type="submit" value="Login" name="signin" id="signin" style="background-color:blue;"
					   style="color:white" style="font:bold"></td>
				  </tr>
				
			</table>
			</form>
		
		</body>

<?php
	}
?>


Is This A Good Question/Topic? 0
  • +

Replies To: How an user can access particular contents in application

#2 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: How an user can access particular contents in application

Posted 13 October 2009 - 12:29 AM

try to user $_GET in function

index.php page

after login successfully
...
header("Location: tab7.php?uid=$userid");


tab7.php page
select * from tblprofile where userid=".$_GET['uid'];

:)
Was This Post Helpful? 0
  • +
  • -

#3 Ghost rider  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 158
  • Joined: 29-October 08

Re: How an user can access particular contents in application

Posted 13 October 2009 - 02:45 AM

Hey noorahmad,
thank for your reply. I tried to do your suggestion but all the users are access tabs7.php and all see all the contents.
Question?
1-if you can clarify! if the user become a member then create a profile or contents in tabs7.php. How tabs7.php can have different profiles or contents of different users? That it's upgrade itself every time a new user become a member? I'm no sure, I believe that could be the problem! Because in index.php when the user login successfully it take user to tabs7.php regardless their user id!
Was This Post Helpful? 0
  • +
  • -

#4 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: How an user can access particular contents in application

Posted 13 October 2009 - 03:36 AM

ok what need to do is filter your query in tabs7.php page,
here is a quick example:
login.php page
session_start();
// check for username and password, if it is not post then assign NULL
$username = isset($_POST['username']) ? $_POST['password'] : NULL;
$password = isset($_POST['password']) ? $_POST['password'] : NULL;

if($username == NULL || $password == NULL){
	//if username or password is empty then go back to index.php page and show msg using echo $_GET['msg'];
	header("Location: index.php?act=login&msg=Please+type+username+and+password");
}

// run user query
$query = mysql_query("SELECT * FROM tblusers WHERE Username='$username' AND Password='$password'")or die(mysql_error());

// if user login successfully then mysql_num_rows() will > 0
if(mysql_num_rows($query)>0){

	// get all data from database to $result as an array
	$result = mysql_fetch_assoc($query);
	$_SESSION['Username'] = $username;
	
	// Get Userid from database if users login successfully	
	$userid = $result['Userid']; 
	header("Location: profile.php?uid=$userid");
}else{
	header("Location: index.php?act=login&msg=Invalid+username+or+password.");
}


and here is profile.php page
if(isset($_GET['uid'])){	
	$uid = $_GET['uid'];
	$query = mysql_query("SELECT * FROM tblprofile WHERE Userid=$uid")or die(mysql_error());
	$result = mysql_fetch_assoc($query);
	echo $result['About']// what you wnat	
}


:)
Was This Post Helpful? 0
  • +
  • -

#5 Ghost rider  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 158
  • Joined: 29-October 08

Re: How an user can access particular contents in application

Posted 15 October 2009 - 03:04 AM

Hey,
I tried, and its denying any user for access tabs7.php. and it illustrated these messages after user tried to login:

Warning: mysql_query() [function.mysql-query]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\myproject1\Tabs7.php on line 4

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\myproject1\Tabs7.php on line 4
Access denied for user 'SYSTEM'@'localhost' (using password: NO)


tabs7.php script

<?php
if(isset($_GET['uid'])){  
			  $uid = $_GET['uid'];		
		  $query = mysql_query("SELECT * FROM login WHERE User_id=$uid")or die(mysql_error());	  
		  $result = mysql_fetch_assoc($query);		
			  echo $result['About']; // what you wnat   
}


?>

<html>
	<head>

		<title>tabs</title>
			<link rel="stylesheet" type="text/css" href="tabcontent.css" />

		<script type="text/javascript" src="tabcontent.js">



		</script>
	</head>

<body>
<img src="image1/mycontSmallLogo.gif">

<br>
<ul id="countrytabs" class="shadetabs">
	<li><a href="#" rel="country1" class="selected">Photos</a></li>
	<li><a href="#" rel="country2">Countries</a></li>
	<li><a href="#" rel="country3">Business</a></li>
	<li><a href="#" rel="country4">Bakong Gentleman(Fashion)</a></li>
	
	<li><a href="#" rel="country5">user space</a></li>
	
	
	
	
	
</ul>

<div style="border:1px solid gray; width:1050px; margin-bottom: 1em; padding: 10px">

	<div id="country1" class="tabcontent">
	 <?php include ("gallery.html"); ?>

		News, videos,photos and many more around Africa<br/>
		<table border="1">
			<tr>
				<td> Angola(Luanda)</td>
				<td><img src="image1/Copy of Calcadao.JPG" width="150" height="100"></td>
			</tr>
			<tr>
				<td>(Luanda)Sunset</td>
				<td><img src="image1/Copy of Sunset.JPG" width="150" height="100"></td>
			</tr>
			<tr>
				<td>Angola(Luanda)</td>
				<td><img src="image1/Copy of calcadaoni1.JPG" width="150" height="100"></td>
			</tr>
		</table>
	</div>

	<div id="country2" class="tabcontent">
			
		<?php include ("AfricaMap1.php"); ?> 	
		
	</div>

	<div id="country3" class="tabcontent">
		<?php include ("AfricanBus1.php"); ?> 
	</div>
	
	<div id="country4" class="tabcontent">
		
		<?php include ("BakongGent1.php"); ?> 
 
	</div>
	
	
	
	<div id="country5" class="tabcontent">
		<?php include ("thumb.php"); ?> 
		<?php include ("immigration1.php"); ?>  
 
	</div>

	
	
	
	

	

	
</div>




<script type="text/javascript">

var countries=new ddtabcontent("countrytabs")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>





</body>

</html>

Was This Post Helpful? 0
  • +
  • -

#6 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: How an user can access particular contents in application

Posted 17 October 2009 - 02:17 AM

first you need to connect to your localhost
put this code at top of your every page
$host = "localhost";
$user = "root"; //change it if required
$pass = ""; //change it if required
$db = "mydb"; //change it to your database name
$con = mysql_connect($host,$user,$pass)or die(mysql_error());
$db = mysql_select_db($db)or die(mysql_erro());


or save it in a PHP file and include it in every page :)
Was This Post Helpful? 0
  • +
  • -

#7 Ghost rider  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 158
  • Joined: 29-October 08

Re: How an user can access particular contents in application

Posted 19 October 2009 - 04:15 AM

I put this part of script on top of tabs7.php.
Note: I'm not using any password to access mysql that why I left it empty. But Also I tried with password It still show the same error message with yes password. Thank in advance
$host = "localhost";

$user = "root";

$pass = "";

$db = "mycontinent";
$con = mysql_connect("$host", "$user, $pass") or die ("Could not connect");
$db = mysql_select_db($db) or die ("Could not select DB");


This error.
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root, '@'localhost' (using password: NO) in C:\wamp\www\myproject1\Tabs7.php on line 11
Could not connect

Was This Post Helpful? 0
  • +
  • -

#8 Ghost rider  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 158
  • Joined: 29-October 08

Re: How an user can access particular contents in application

Posted 20 October 2009 - 03:17 AM

[quote name='Ghost rider' date='19 Oct, 2009 - 03:15 AM' post='803575']
I put this part of script on top of tabs7.php.
Note: I'm not using any password to access mysql that why I left it empty. But Also I tried with password It still show the same error message with yes password. Thank in advance
$host = "localhost";

$user = "root";

$pass = "";

$db = "mycontinent";
$con = mysql_connect("$host", "$user, $pass") or die ("Could not connect");
$db = mysql_select_db($db) or die ("Could not select DB");


This error.
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root, '@'localhost' (using password: NO) in C:\wamp\www\myproject1\Tabs7.php on line 11
Could not connect


Hi,
ignorant above error, I managed to find out why it was illustrate that error because I didn't change this part:
if(isset($_GET['uid'] to  this  if(isset($_GET['user_id'])) 


But now any characters the user put in login box let user to login or it meant it just by pass the password and let user to go to next page.

May be I need to explain let be better how the structure of the application:

1- index.php- where the user need to login to go next page, after they sign in to become a member.
2- the user details are database- table login.
3-tab7.php where user can view their content and upload new content. details of content is store in database and images are store in directory.

I don't know if the problem with table relationship, or I need to create more table to each user to access their content without view other users contents?

or I need to create each user with their own application to view their contents. But that it'll difficult for the the system. Because every time new user become a member all details go to one place.
Thank in advance if anyone can come with some good explaining and example of script.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1