Phty5h Posted July 8, 2006 Share Posted July 8, 2006 Hi there.... In order to ask this question effectivly, i will give you my testing webserver so you can see what im talking about [url=http://cbmanagment.co.nr/]http://cbmanagment.co.nr/[/url]If you navigate to the CV services section, and then click on the link to the Form that is what im talking about here.(and yes i know the navigation bar sucks, im working on it ;D)Ok, so in the last 3 months ive learnt enough to create this little form you see, It uses hidden fields to pass data between the pages, and then sends all the gathered info as an email to my inbox.Im quite please with this ..... but, im afraid it needs to go further.I need to be able to do the following;1) Restrict access to the form to those people who have paid a fee for the service (membership system)2) Store the information entered by each member so that they can come back and change it at a later date... or in fact take there time over filling it out... at the moment it all must be filled and submitted in a oner, and the form is unforgiving of mistakes.3)related to above, I need to allow the user to freely navigate back and forth within there form, and modify as they see fit.Further more i need this to be supported on both firefox and IE V 6 and above.Now i'm pretty sure i need to set up a MySql database in order to accomplish this, however this is my first contact with MySql... and to be honest im finding it difficult to find solid advice on getting started.I am using Dreamweaver MX2004 for my design, but am quite happy (and prefer even) to code by hand where possible.I also have WAMP installed and running nicley.... Ive looked at PhpMyadmin, but im not really sure where to start.Im not looking for anyone to do this for me.... i want and in fact need to learn..... but someone to nudge me in the right direction would be most satisfactory.You have my greatest thanks for any and all of your help :) Quote Link to comment https://forums.phpfreaks.com/topic/14024-really-basic-mysql-database/ Share on other sites More sharing options...
Aftek Posted July 11, 2006 Share Posted July 11, 2006 I'm actually trying to make a user management system too,so im not an expert.. yet ( hopefully lol ).but at least some basics,you can use session with php.when you use session_start(), php will give the viewer a random unique session id.and when your session is started you can user $_SESSION['var'] variables.(i think using $_SESSION['var'] starts one automatically.. not sure).so lets say you have$_SESSION['username'];You create a login form that will set this variable...and a logout page that will unset it.( since you can have many many more session variables, you should use session_destroy() so you dont have to unset one by one each variablesit does it all at once ).now for your session to carry out to other page, along with its variables, you have 2 choices.within the url ( http://urDomain/?PHPSESSID=the session id )or with a cookie.using cookie is much safer... read your php.ini at session section.you either need to session_start() on every page, oryou can set session_auto_start in php.ini so every pageretrieve the session variables..ex for something you want to registered members only:[code]<?phpif (!isset ($_SESSION['username'])){ echo "Please login/register to access this";}else{ //show the form you reserved to registered users}?>[/code]2 ) now for user information to be edited[code]<?php// if the user is not even logged in...if (!isset ($_SESSION['username'])){ echo "You shouldnt even be here! Shoo"; //you can redirect to login page too}// else if the logged user has not wished to edit yet.elseif (!isset ($_POST ['edit'])){ //you simple list the information you have in your database}// else means the logged users wishes to edit this time.else{ //now's the biggest part.... the form, the validation and entering in database //if you unset $_POST['edit'] once the data is saved you can redirect to the same page too.}?>[/code]for your 3) dunno if thats what you need but... if your getting started you should use mysqli right away..( enable the extension and get the files at mysql.com i think )with mysqli there's an oop available and much easier/safer i think[code]<?php//you first need to know the info about your database$username = "username";$password = "password";$db_host = "the address to your database server"; // ip, url, localhost...$db_schema = "the schema where you'll be able to create view alter you tables";//then you create a mysql connection as a mysqli object$mysqli = new mysqli ($db_host, $username, $password, $db_schema);//if you have a INSERT or ALTER query then simply//you can then check for errors with mysqli_error() or mysqli_errno() $mysqli->query ($urQuery);//if you have a SELECT query then it will give you another object to handle results$result = $mysqli->query ("SELECT...FROM..");//then you get$result->num_rows; // which is the number of rows returns by the query//each time you call this, you pass to the next row, first time getting first row.$row = $result->fetch_assoc(); // you get an array of eacg colym of you query by colum name $row['column_name1'], etc..//so you can either do$i=0while ($i < $result->num_rows){ $row = $result->fetch_array(); // you get an array of each column of your query order in $row[0], $row[1] etc}//or dowhile ($row = $result->fect_both()){ // do whatever you want with data accessible by $row['0'] or $row['column_name1'] etc...}alright.. its late i need sleep :)I too in fact hope to get feedback of my use of php..so i hope it does help you, and if you need some thing clarified, seen how im tired i wont be surprised..?>[/code]good luckalright... if it helps... or if i can clarify some things for you, itll be my pleasure...im hoping to get comments on my comment too lolcya Quote Link to comment https://forums.phpfreaks.com/topic/14024-really-basic-mysql-database/#findComment-56041 Share on other sites More sharing options...
Phty5h Posted July 11, 2006 Author Share Posted July 11, 2006 Thanks for your time and help mate......... but i think im even more confused now (if possible).1) where is all this username info stored?2) how is it retrieved?3) how do i get a mysql database that i create at localhost onto my webserver?basic question i know.... but im not even at the code writing stage yet :( Quote Link to comment https://forums.phpfreaks.com/topic/14024-really-basic-mysql-database/#findComment-56322 Share on other sites More sharing options...
Aftek Posted July 11, 2006 Share Posted July 11, 2006 hehe well sorry for confusing..1) - when you use session_start(), php sends the session id to the viewing browser/user - with this id , every different user will have his own set of session variable as in $_SESSION['name of the var'] for example, user A with his unique session id gets $_SESSION['username'] = "john"; while user B with another unique session id gets $_SESSION['username'] = "smith";2) when u use session_start() it ONLY assign the id... to check if it exist first, you should have if (isset ($_SESSION['username'])) before. and you can retrieve it with: $username = $_SESSION['username']; if you make sure to unset/destroy session variables when user log off... and dont set your session variable until the user has provided info to log in... the if it is not set... the user is simply guest... otherwise.. you can retrieve any session variables you might need.3) if you follow all steps in [url=http://www.adcommcepts.com/wamp-install.pdf]http://www.adcommcepts.com/wamp-install.pdf[/url] (found on from apache lounge) you should then have a workin apache 2.2.2 php 5.1.4 and mysql 5.0.22 installation. i recommend installing mysql administrator and query browser which you can get from mysql.comfinally, if you are starting, let me recommend once more using mysqli extension instead of mysql...mysqli being mysql improved extensionif not in you php.ini simply copy paste the mysql extension line, uncomment and add a 'i' to make mysqlialright... cya next break if i have time :) lolsorry again for confusing... i hope the guide[url=http://www.adcommcepts.com/wamp-install.pdf]http://www.adcommcepts.com/wamp-install.pdf[/url] is clearer than me :)and it will get you the latest released version working...and be sure to check www.apache-lounge.com dedicated to apache under windows,but many information, they too provide the php 5.1.4 apache2.2.2 connector.(for you server to understand the last version of php code)... read the guide, and tell me Quote Link to comment https://forums.phpfreaks.com/topic/14024-really-basic-mysql-database/#findComment-56393 Share on other sites More sharing options...
jpratt Posted July 25, 2006 Share Posted July 25, 2006 1. The username and password should be stored in a table in your database. When the user logs in it checks to see if the record exists in that table with a valid password. Then if it is correct, store the username as a session varible, or run queries to get the information needed based on the user that logged in.2. The SQL statement that is used to retrieve client information will be custom depending on what information you need and how your database is set up. Google some SQL tutorials to see how to retrieve data thru SQL statements.3. To move your db from your local machine to your web server, you create a .sql backup of your database on you local computer. Their should be a operations section under MySQL Administrator if your using that. Anyway that created a .sql file this contains a bunch of create table commands and insert commands. Copy and paste this into a SQL window within phpmyadmin for your web server database and run it. It will create your tables and populate them for you, (if you have any data yet that is). Quote Link to comment https://forums.phpfreaks.com/topic/14024-really-basic-mysql-database/#findComment-63406 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.