PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 12th, 2009, 07:47 AM
Ghost rider Ghost rider is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 70 Ghost rider User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 10 h 21 m 29 sec
Reputation Power: 1
How user can access particulary script in application

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


Code:
<?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
	}
?>

Reply With Quote
  #2  
Old October 19th, 2009, 02:51 AM
icandothat's Avatar
icandothat icandothat is offline
Super Moderator
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 1,657 icandothat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 22 h 10 m 4 sec
Reputation Power: 4
without reading your script I'll explain the basics how how something like this would be done. User 'a' posts some content. this content is stored either in the file system somewhere or in the database and a record is stored in the database recording the relationship between user and content.
in another table relationships between users are stored in the database.
finallly when a user logs in a query is run to determine who he is related. then a query is run to gather recent content from those people and this content is displayed.
__________________
There is no spoon.

Reply With Quote
  #3  
Old October 19th, 2009, 12:25 PM
Ghost rider Ghost rider is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 70 Ghost rider User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 10 h 21 m 29 sec
Reputation Power: 1
Thank for your reply. I couldn't get all about your explaining. But could you illustrated in code about relationship of tables.

1- that meant every user must have a table to be able to access after login!
2-every time new user sign in automatically must create a table, how!

Reply With Quote
  #4  
Old October 19th, 2009, 02:22 PM
icandothat's Avatar
icandothat icandothat is offline
Super Moderator
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 1,657 icandothat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 22 h 10 m 4 sec
Reputation Power: 4
Goodness no.

here is an example of a relational database design to support your needs.

Code:
 -- Users --
userid
username


-- UserRelationships --
User1ID
User2ID


-- UserContent --
UserID
ContentType
ContentPath
ContentDesc


of course this is very simplistic but I think it should get the basic idea accross. You may want to do some reading about relational databases.

Reply With Quote
  #5  
Old October 20th, 2009, 06:24 AM
Ghost rider Ghost rider is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 70 Ghost rider User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 10 h 21 m 29 sec
Reputation Power: 1
Thank for your reply. you meant I'll need to create three tables? and if you have some new suggestion about this let me know!

Reply With Quote
  #6  
Old October 20th, 2009, 07:23 AM
jamestrowbridge jamestrowbridge is offline
Contributing User
Click here for more information.
 
Join Date: Jul 2008
Location: Cleveland, Ohio, USA
Posts: 411 jamestrowbridge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 18 h 54 m 24 sec
Reputation Power: 2
Yeah, he's suggesting three tables,
one to authenticate against and to store all users, etc

one to store whether or not 2 (or more) users are 'friends' or not

and finally one to store all of the data that will be shown to user 'a' and, if user 'a' is 'friends' with user 'b' - to user 'b' too.
__________________
Sir, a desire of knowledge is the natural feeling of mankind; and every human being, whose mind is not debauched, will be willing to give all that he has to get knowledge.

Reply With Quote
  #7  
Old October 20th, 2009, 08:31 AM
Ghost rider Ghost rider is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 70 Ghost rider User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 10 h 21 m 29 sec
Reputation Power: 1
Quote:
Originally Posted by jamestrowbridge
Yeah, he's suggesting three tables,
one to authenticate against and to store all users, etc

one to store whether or not 2 (or more) users are 'friends' or not

and finally one to store all of the data that will be shown to user 'a' and, if user 'a' is 'friends' with user 'b' - to user 'b' too.


Thank you for reply. At moment I do have only one table. it's authentication table, this table after use become a member all his details store. example below:
login table.
User-id
username
userpass
firstname

Please could you explain better about the second table and third? how they have relatioship and if you could illustrate in code I'll appreciate.

Reply With Quote
  #8  
Old October 20th, 2009, 08:51 AM
jamestrowbridge jamestrowbridge is offline
Contributing User
Click here for more information.
 
Join Date: Jul 2008
Location: Cleveland, Ohio, USA
Posts: 411 jamestrowbridge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 18 h 54 m 24 sec
Reputation Power: 2
So you have an authentication table...

How were you going to be storing the information that the user sees? you know: photos, contacts, etc ?

Reply With Quote
  #9  
Old October 21st, 2009, 05:20 AM
Ghost rider Ghost rider is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 70 Ghost rider User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 10 h 21 m 29 sec
Reputation Power: 1
I do have another table to upload details of photos and comments. But the photos are store in directory.

This the structure of table upload.

id
photo_name
Type
path
comments

Thank in advance

Reply With Quote
  #10  
Old October 21st, 2009, 07:27 AM
jamestrowbridge jamestrowbridge is offline
Contributing User
Click here for more information.
 
Join Date: Jul 2008
Location: Cleveland, Ohio, USA
Posts: 411 jamestrowbridge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 18 h 54 m 24 sec
Reputation Power: 2
okay, so now you need to add another column to that table to store the username. And then build another table for the user relationships.

with the columns, if there will be different types of friends (or whatever) maybe you would want another column called type or something.
id
user1
user2

Once all of the tables have been created, when you are building the application, just add users to the authentication table, and content to the 'upload' table (or whatever you are calling it) be sure to store the username of the person who owns it in the username column of that table too, and then when two users become friends, this will add to the 'relationship' table, one row for each relationship.
If you delete users and want to remove everything they had on your app, delete their record from the auth table, any record(s) they had in the 'upload' table, and any records where either user1 or user2 = their username in the 'relationship' table.

This is a lot of code, so start writing it, if you have trouble - repost.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > How user can access particulary script in application


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek