pranshu82202 Posted July 10, 2011 Share Posted July 10, 2011 I am a student and learning php. Actually i have my code ready. I have created the registration page. A php script to send registration details to database. I have created a login page. A php script to verify the login I have created a general page for all user which have some text fields. Url of the page be like (http://abc.com/everyone.php?id= ( Here ID is the id of the registered user) (Anyone can access this page) in which any (even non registered or logged in ). When user enter data the data automatically inserts into my sql database with the id of the registered user. I have successfully inserts all the data except the id of the owner of the page. And also tell me how shuld i create such a url ... And what shuld be the name of the general page (everyone.php) I am pissed off .... Quote Link to comment Share on other sites More sharing options...
spiderwell Posted July 10, 2011 Share Posted July 10, 2011 when you have your login script do you store the userid into the session variable? there must be some mechanism that you use to keep users logged in and identify them. use that to extract your userid. Quote Link to comment Share on other sites More sharing options...
pranshu82202 Posted July 10, 2011 Author Share Posted July 10, 2011 the php page in which i verify the login, $username = $_GET['usname']; $userpass = $_GET['uspass']; $username = stripslashes($username); $userpass = stripslashes($userpass); $username = mysql_real_escape_string($username); $userpass = mysql_real_escape_string($userpass); $sql = "select * from logintable where us_name='$username' and us_pass='$userpass'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("usname"); session_register("uspass"); $userPrimaryKey1 = "select id from logintable where us_name='$username'"; $userPrimaryKey=mysql_query($userPrimaryKey1); // Now from here the problem starts // I want to redirect user to a member page (only accessible to mebers) // In which i will provide him a url (Corresponding to his id) (and accessible to anyone) // When someone enters the url and insert some value in the url i want to store those in my database with a id field (id of the user to which this url belong) echo "Your generalized url is " echo 'http://abc.com/everyone.php?id='.$userPrimaryKey.''; // please tell me weather i write it correct or not. else { echo "<br>"; echo '<center>'."Wrong Username or Password".'</center>'; } Quote Link to comment Share on other sites More sharing options...
pranshu82202 Posted July 10, 2011 Author Share Posted July 10, 2011 Also tell me waht is the significance of the word id in the url. (http://abc.com/everyone.php?id= Quote Link to comment Share on other sites More sharing options...
spiderwell Posted July 10, 2011 Share Posted July 10, 2011 id is the variable name being passed, you could use anything as long as you know what you are using that variable for. Quote Link to comment Share on other sites More sharing options...
pranshu82202 Posted July 10, 2011 Author Share Posted July 10, 2011 is id the column name of the table in mysql database ?? Or its just the variable... If its just a variable then what is the sense of http://abc.com/everyone.php?id=8 Please elaborate this.... I want it very badly.... Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 I don't quite understand what you're wanting to do, but, on the "everyone.php?id=#" are you wanting to display the users information with the ID of #? Quote Link to comment Share on other sites More sharing options...
pranshu82202 Posted July 10, 2011 Author Share Posted July 10, 2011 Let me elaborate i have a page everone.php in which their is a text field. and their is a link http://abc.com/everyone.php?id= which displays same page everyone.php but when someone enters an any value in the textfield it get stored in my database with the id of the user with which it belongs... Plzz Help me i want to create something exactly like www.crushbits.com. You plzz access this site and you'll get to know what i want to create... You guyzz are great ... Plzz Help Me Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Correct me if I'm wrong, you want it to be like: IF I enter the value of '3'; It goes and finds the user with the id value of '3', then stores it in the database? Quote Link to comment Share on other sites More sharing options...
pranshu82202 Posted July 10, 2011 Author Share Posted July 10, 2011 if you are on the page http://abc.com/everyone.php?id=8 and you enter the value "helllo" then it will store 8 in the id column and hello in the value column of my database.... plzz refer http://dumbo.im and you will get to know what i am saying... Plzzzz Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 What I'm asking is, is the "id" variable connected to the Users "id"? ID // NAME 1 // ANDY 2 // JAMES 3 // TEST If the ID = 1, it will send it to Andy. If the ID = 2, it will send it to James. If the ID = 3, it will send it to Test. Is that what you're onabout? We can't help you not knowing what the 'id' variable in the URL is related to. Quote Link to comment Share on other sites More sharing options...
pranshu82202 Posted July 10, 2011 Author Share Posted July 10, 2011 first of all users register to my site. After which i allot them a username, password, id (an auto increment column and a primary key ) This is the id ... When the registered user log in We redirect them to the members page which looks somewhat like this -------------------------------------------------------------------------------------------------- Welcome, Your personal url is http://abc.com/everyone.php?id= 8 (You can give this url to anyone) here is the data which others enter with your url xyz abc ... .. . -------------------------------------------------------------------------- Did you get what i am trying to say..... Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Do you have MSN or anything? I think it'd be easier to help what you want to do as I'm starting to get the idea of what you mean. What you're wanting is the 'id' in the URL to be connected to the user 'id', which will then show the page, but when entered, it sends it accordingly to the 'id' that is connected to the user. Quote Link to comment Share on other sites More sharing options...
pranshu82202 Posted July 10, 2011 Author Share Posted July 10, 2011 Exactly... Well i m on gtalk pranshu.a.11@gmail.com You can add me if you are also on gmail Well can you tell me the code of the verification page (login verification page) and the code of everyone.php page and the code of php which inserts the data into the database..... It would be damn good if you provide me these... PLZZ HELP Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 I'll need to see your codes, and then I can show you how to make it, pretty much, to show the link once they registerd, add this to "sucess" part of your register.php page: $getIDQ = mysql_query("SELECT * FROM `tbl_name` WHERE `username`='".$user."'"); $getIDF = mysql_fetch_assoc($getIDQ); echo 'Your link is: http://abc.com/everyone.php?id='.$getIDF['id']; Adapt the code to how you need. ------------------------------------------------- On the Everyone.php page, use this: $id = $_GET['id']; $get_user = mysql_query("SELECT * FROM `users` WHERE `id`='".$id."'"); $user_info = mysql_fetch_assoc($get_user); adapt that also. ----------------------------------------- When they send the 'value' Use the query like: $user = $user_info['username']; $value = $_POST['value']; $send = mysql_query("INSERT INTO `tbl_name` VALUES ('', '$user', '$value')"); If thats how you want it, I think thats what you mean. Quote Link to comment Share on other sites More sharing options...
pranshu82202 Posted July 10, 2011 Author Share Posted July 10, 2011 Thats so kind of you.... Thanks for your such great help... Plzz tell me in everyone.php from where it will get the id.... Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 As long as your URL looks like: http://www.example.com/everyone.php?id=# the use of: $_GET['id']; will grab the ID from the URL. To test that, open up your everyone.php document and type in there: echo $_GET['id']; then go to your site and test it. Quote Link to comment Share on other sites More sharing options...
pranshu82202 Posted July 10, 2011 Author Share Posted July 10, 2011 Thank you so much sir but when i run my verify.php {your first provided code} it says error that mysql_fetch_assoc(): supplied argument is not a valid MySQL result what shuld i do... ???? Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Try the other version: mysql_fetch_array(); Quote Link to comment Share on other sites More sharing options...
pranshu82202 Posted July 10, 2011 Author Share Posted July 10, 2011 i tried this also but gives same error Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Ermm, would you be willing to download some software called "Teamviewer" which would allow me to view/control your screen so I can have a look at the code and see if theres any errors with anything else? Quote Link to comment Share on other sites More sharing options...
pranshu82202 Posted July 10, 2011 Author Share Posted July 10, 2011 Sir i solved it ... Now its working..... Sir it was great having a conversation with you... Thanxx a lot.... If i'llbe having any problem i will contact you... Hope you wont mind it..... Thanx a lot again Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Thats fine, I'm not the best at PHP, but I'll help you as much as I can. Don't forget to press "Topic Solved". Regards, Andy. Quote Link to comment Share on other sites More sharing options...
pranshu82202 Posted July 10, 2011 Author Share Posted July 10, 2011 Sir one more help plzz... On the Everyone.php page, use this: Code: [select] $id = $_GET['id']; $get_user = mysql_query("SELECT * FROM `users` WHERE `id`='".$id."'"); $user_info = mysql_fetch_assoc($get_user); adapt that also. ----------------------------------------- When they send the 'value' Use the query like: Code: [select] $user = $user_info['username']; $value = $_POST['value']; $send = mysql_query("INSERT INTO `tbl_name` VALUES ('', '$user', '$value')"); Can you plzz little bit explain these codes..... Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Go get Teamviewer, I'll show you what I mean. I'm horrible at explaining. ~Andy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.