|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#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>          
<input type="text" id="username" name="username"></p></td>
</tr>
<tr>
<td><p style="color:gray"><b>Password</b>    
<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
}
?>
|
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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! |
|
#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. |
|
#5
|
|||
|
|||
|
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!
|
|
#6
|
|||
|
|||
|
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. |
|
#7
|
|||
|
|||
|
Quote:
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. |
|
#8
|
|||
|
|||
|
So you have an authentication table...
How were you going to be storing the information that the user sees? you know: photos, contacts, etc ? |
|
#9
|
|||
|
|||
|
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 |
|
#10
|
|||
|
|||
|
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. |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > How user can access particulary script in application |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|