Hello,
I'm new in the forum and in php .I have started to do experiments with PHP. Now i have a problem that I can not figure out how to slove it.On my webpage I have login form and i wanna make page for each user- where they will have avatar, name and link with their names.This link will gives points- when someone click on it the user will recive 1 point. This page must be visible to all because the user will recive point after each click.
If you could give me the finished code will grateful to you.
9 replies to this topic
#1
Posted 18 June 2011 - 01:46 PM
|
|
|
#2
Posted 18 June 2011 - 04:06 PM
What do you have so far?
#3
Posted 18 June 2011 - 11:21 PM
Hello portosbg, before learning how to actually write the code you can visualize what is needed.
The database for example can contain the following fields:
Assuming you have made the signup form to put their information in the database, and that the table was already created before that to hold the data you could pull their data out of the actual address. Imagine the address is this:
You could also run a query after that to update their points if the user exists, simply something such as:
Feel free to read appropriate tutorials on how to connect with the database, and see what you can come up with.
The database for example can contain the following fields:
id, username, password, avatar, pointsid could be automatically assigned to new users by MySQL, loginname (or just username if you wish) could hold their displayed name, avatar can hold a link to their avatar image (i.e. /images/avatar2043.png) and however you wish to make this.
Assuming you have made the signup form to put their information in the database, and that the table was already created before that to hold the data you could pull their data out of the actual address. Imagine the address is this:
page.php?user=john (or id=2)You could access their ID from $_GET['user'] or $_GET['id'].
if( is_int($_GET['id']) ) {
$id = $_GET['id'];
...
}And run the appropriate queries, i.e.SELECT id, username, avatar, points FROM users WHERE id = $idYou can then extract the data with mysql_fetch_assoc and display the unique information based on their database record (or error if not exists)
You could also run a query after that to update their points if the user exists, simply something such as:
UPDATE users SET points = points + 1 WHERE id = $id
Feel free to read appropriate tutorials on how to connect with the database, and see what you can come up with.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#4
Posted 19 June 2011 - 03:57 AM
10X man .Can you tell me how to make url link with $_GET value ?
Edited by portosbg, 19 June 2011 - 04:59 AM.
#5
Posted 19 June 2011 - 11:46 PM
Each parameter will automatically populate the $_GET superglobal array. For example, foo=2&baz=a will populate both $_GET['foo'] and $_GET['baz'] in your code. You must check if they exist however and throw an error if they do not, so that you do not accidentally run the code if they are not supplied.
You must also verify the data within is correct, you would not want the user manually changing the parameters to something malicious if you were to rely on them for database actions.
You must also verify the data within is correct, you would not want the user manually changing the parameters to something malicious if you were to rely on them for database actions.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#6
Posted 21 June 2011 - 11:17 AM
Hi again .I made what i wanna 10x. Now appear new problem -how can make to vote once a day from ip
#7
Posted 21 June 2011 - 12:10 PM
mark a vote in a table with voting user, voted item and timestamp. if it's 24 hours later than the timestamp, let them vote again and update the timestamp, otherwise don't let them vote.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall
#8
Posted 22 June 2011 - 01:00 PM
Can you give code pls
#9
Posted 22 June 2011 - 07:53 PM
Also you could make use of a .HTACCESS rewrite to make the URL's more user friendly. For example you could rewrite the URL http://site.com/user/steve to http://site.com/user.php?name=steve using this code in your .HTACCESS file-
Options +FollowSymlinks RewriteEngine On RewriteRule ^user/(.*) user.php?name=$1
#10
Posted 23 June 2011 - 02:05 PM
10x :cool:
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









