Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

MySQL Database Login/Registration

Options
  • 04-01-2010 11:47pm
    #1
    Closed Accounts Posts: 112 ✭✭


    Hi,
    I am doing a website builder web 2.0 project and stuck on something, I want my database to store username, email, password, title & full name. The title means the title of the website in which they are creating....

    I have created a registration form on beta.gahim.com/start which recives data (via PHP Post) from beta.gahim.com....

    The database name is: members

    Unfortunatly I am new to this so step-by-step instructions would be fantastic, thanks!


«1345

Comments

  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Can you not get the hint? :rolleyes:


  • Closed Accounts Posts: 112 ✭✭gahim


    Webmonkey wrote: »
    Can you not get the hint? :rolleyes:

    The link doesn't go anywhere, it goes to a board.ie error page :rolleyes:, I need step by step instructions as I am new.... :confused:


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Here: http://www.boards.ie/vbulletin/showthread.php?t=2055787433

    No you don't need step by step instructions because nobody will give them to you. You need to go research a bit, make an attempt and then show us code or something explaining where you are getting stuck.

    How will you build such a website builder site if you cannot achieve this. You are jumping ahead of yourself I think.


  • Closed Accounts Posts: 112 ✭✭gahim


    Webmonkey wrote: »
    Here: http://www.boards.ie/vbulletin/showthread.php?t=2055787433

    No you don't need step by step instructions because nobody will give them to you. You need to go research a bit, make an attempt and then show us code or something explaining where you are getting stuck.

    How will you build such a website builder site if you cannot achieve this. You are jumping ahead of yourself I think.

    The link you sent went to another one of my threads


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Yeah and it was locked and you were told read the charter.


  • Advertisement
  • Closed Accounts Posts: 112 ✭✭gahim


    Hi,
    What's a charter, why was it closed and why did you just send me back to the previous forum can you send me to a page that can help me?


  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    gahim wrote: »
    Hi,
    What's a charter, why was it closed and why did you just send me back to the previous forum can you send me to a page that can help me?

    Ok, I think you need to understand where we are coming from here.

    The general rule on this forum is that people will not just tell you the answer straight out - you need to show us what you have done, where exactly you are having problems, and how you have attempted to fix the problem.

    This is to prevent people who never contribute to the forum from just wandering in, getting the answer they want, and never contributing to the forum again.

    So, show us what you've got. :)


  • Closed Accounts Posts: 112 ✭✭gahim


    I am completely lost, can someone give me a link to a page where it gives me easy instructions?

    Thanks


  • Registered Users Posts: 1,181 ✭✭✭ronkmonster


    You are only supposed to ask for help here.
    Not for us to give you all the code you need to do it.

    If you don't know how to link webpage into mysql database why don't you try google it?
    Best put that website builder project on hold until you at least now how to do this.


  • Closed Accounts Posts: 112 ✭✭gahim


    I ran this command in the database

    CREATE TABLE `users` (
    `id` int(3) NOT NULL auto_increment,
    `login` varchar(8) default NULL,
    `password` varchar(8) default NULL,
    PRIMARY KEY (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT=3 ;

    My login.php page has
    <?
    session_name
    ("Login");
    session_start();
    session_destroy();
    if($_GET/COLOR][COLOR=#dd0000]'login'[/COLOR][COLOR=#007700 == "failed") {
    [COLOR=blue ! important][COLOR=blue ! important]print[/COLOR] [/COLOR]$_GET/COLOR][COLOR=#dd0000]'cause'[/COLOR][COLOR=#007700;
    }
    ?>
    <form name="login" method="post" action="log.php?action=login">
    Username: <input type="text" name="username"><BR>
    Password: <input type="password" name="password"><BR>
    <input type="submit" value="Login">
    </form>


    Log.php has
    <?
    session_name
    ("MyLogin");
    session_start();
    if($_GET/COLOR][COLOR=#dd0000]'action'[/COLOR][COLOR=#007700 == "login") {
    $conn = mysql_connect("localhost","username","password"); // your MySQL connection data
    $db = mysql_select_db("members"); //put your database name in here
    $name
    = $_POST/COLOR][COLOR=#dd0000]'user'[/COLOR][COLOR=#007700;
    $q_user = mysql_query("SELECT * FROM USERS WHERE login='$name'");


    if(mysql_num_rows($q_user) == 1) {

    $query
    = mysql_query("SELECT * FROM USERS WHERE login='$name'");
    $data = mysql_fetch_array($query);
    if($_POST/COLOR][COLOR=#dd0000]'password'[/COLOR][COLOR=#007700 == $data/COLOR][COLOR=#dd0000]'password'[/COLOR][COLOR=#007700) {
    session_register("name");
    header("Location: /builder"); // success page. put the URL you want
    exit;
    } else {
    header("Location: login.php?login=failed&cause=".urlencode('Wrong Password'));
    exit;
    }
    } else {
    header("Location: login.php?login=failed&cause=".urlencode('Invalid User'));
    exit;
    }
    }

    // if the session is not registered
    if(session_is_registered("name") == false) {
    header("Location: login.php");
    }
    ?>


    To customise pages
    <?
    require("log.php");
    ?>
    Printing the user name in the screen is very easy. Just add this code:
    <? print $_SESSION/COLOR][COLOR=#dd0000]"name"[/COLOR][COLOR=#007700; ?>




    Put now what about the register, and am I doing everything right?


  • Advertisement
  • Registered Users Posts: 515 ✭✭✭NeverSayDie


    gahim wrote: »
    I am completely lost, can someone give me a link to a page where it gives me easy instructions?

    Thanks

    No, we can't. OP, software development isn't easy, and in particular it doesn't lend itself to "here's the step by step thing you need to do to build XYZ non-trivial piece of software". Those of us who do it for a living spent a long time learning how to do it, mostly by practising it - a lot. And it doesn't get particularly easy when you've got that experience, it's still a challenging job to work at - if it wasn't, I wouldn't be this well paid, work these long hours, or enjoy it as much as I do. The fact that somebody already pays me to write code for them means I'm not really interested in writing your code for you, and neither are most other folks here. I am interested in helping you learn to write your own code and build your own software, but handing out solutions on a plate is not how that gets done, even if I had the time and the patience to write your PHP for you.

    First thing you need to get used to is finding answers for yourself. As you've hopefully gathered from the responses here, folks tend to react badly when people come along looking for solutions on a plate, or some step-by-step answer to a problem that simply doesn't have one single solution that can be written out in a few minutes.

    Google is your friend. For instance, if you'd googled "PHP MySQL", this would have been one of the first hits, which should get you started;
    http://www.freewebmasterhelp.com/tutorials/phpmysql


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    A register would be an insert statement.


  • Registered Users Posts: 1,181 ✭✭✭ronkmonster


    Your code looks alright for logging in with one exception. Don't store passwords in plaintext in your database. Do a search on storing a hash on the file, eg. MD5. This will give a finger print of the password which you compare when logging in.

    You need to google for sql insert. First link will explain the basics, you need to make it work with the code you have.


  • Closed Accounts Posts: 112 ✭✭gahim


    So can someone give me a useful link instead of giving out to me?

    The web builder is already done, now it's the SQL, this is the last day until I have to publish and complete it, only needed is the registration and login form, login form I think is done now its just the registration...


  • Closed Accounts Posts: 112 ✭✭gahim


    Hi Everyone,
    For the database to store information such as

    the title, email, username and password

    should I add it to this table, and how do I?

    Thanks

    I have attached the image


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    You'll need to use an SQL Insert statement: http://www.w3schools.com/sql/default.asp

    Then you'll need to execute the statement from you're form through php, find out how to execute sql statememts from php.


  • Closed Accounts Posts: 112 ✭✭gahim


    http://www.w3schools.com/sql/sql_insert.asp

    The error I am getting when I put in
    INSERT INTO users
    VALUES (title, email)

    #1136 - Column count doesn't match value count at row 1

    I have no idea what that means, I was doing some research and it just confused me more, thanks...

    :confused::confused::confused::D:D:D


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    First of all, your users table from before contains id, login, password. Why are you trying to insert Title and email into this table?

    Secondly, if you dont' specify the fields you want to enter, it will assume you want to enter the 3 fields (3) but you only specifying 2 values.

    You need to start with basics and read material on the internet and practice. You can't just throw random code out and hope it works and ask why it doesn't then.


  • Closed Accounts Posts: 112 ✭✭gahim


    gahim wrote: »
    So can someone give me a useful link?

    The web builder is already done, now it's the SQL, this is the last day until I have to publish and complete it, only needed is the registration and login form, login form I think is done now its just the registration...

    Could someone give me the code for SQL insert?


  • Subscribers Posts: 9,716 ✭✭✭CuLT


    gahim wrote: »
    Could someone give me the code for SQL insert?
    http://dev.mysql.com/doc/refman/5.1/en/insert.html


  • Advertisement
  • Closed Accounts Posts: 112 ✭✭gahim


    I need to add the fields email & title...

    I need this done asap, what code should I use to enter into the SQL, I want the database to store

    • Username
    • Password
    • Email
    • Title
    The title is the title of the website...

    What code should I put in, I was on http://www.w3schools.com/sql/sql_insert.asp but the codes just gave me errors.


  • Closed Accounts Posts: 112 ✭✭gahim


    gahim wrote: »
    I need to add the fields email & title...

    I need this done asap, what code should I use to enter into the SQL, I want the database to store

    • Username
    • Password
    • Email
    • Title
    The title is the title of the website...

    What code should I put in, I was on http://www.w3schools.com/sql/sql_insert.asp but the codes just gave me errors.

    Just for confirmation

    INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] users ]
    {email | title} ({expr | DEFAULT},...),(...),...
    [ ON DUPLICATE KEY UPDATE
    col_name=expr
    [, col_name=expr] ... ]

    Is this correct, I just don't want to mess up my database :)

    Thanks


  • Registered Users Posts: 8,070 ✭✭✭Placebo




  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    gahim wrote: »
    I need to add the fields email & title...

    http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
    gahim wrote: »
    I need this done asap

    Not helping your cause.
    gahim wrote: »
    • Username
    • Password
    • Email
    • Title
    The title is the title of the website...

    What code should I put in, I was on http://www.w3schools.com/sql/sql_insert.asp but the codes just gave me errors.

    You need to understand what you are trying to do. You need to understand database structure and how you can use that to store your data.

    Just randomly throwing scripts against a database is going to cause you grief both in the short term and the long term.


  • Registered Users Posts: 1,181 ✭✭✭ronkmonster


    The problem you have is that your database has 3 fields in it and you are only supplying 2 fields. There is a way to show which columns you want your 2 fields to match up to, ignoring the other field (if it is allowed to be null).

    http://www.1keydata.com/sql/sqlinsert.html
    first example here should be enough to continue.


  • Closed Accounts Posts: 112 ✭✭gahim


    I clicked on the SQL tab and entered this into the field
    INSERT INTO users
    VALUES ('title', 'email')

    and the result

    SQL query:
    INSERT INTO users
    VALUES ( 'title', 'email'
    )
    MySQL said:
    #1136 - Column count doesn't match value count at row 1

    :confused::confused::confused::confused::confused::confused:


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    gahim wrote: »
    I clicked on the SQL tab and entered this into the field
    INSERT INTO users
    VALUES ('title', 'email')

    and the result

    SQL query:
    INSERT INTO users
    VALUES ( 'title', 'email'
    )
    MySQL said:
    #1136 - Column count doesn't match value count at row 1

    :confused::confused::confused::confused::confused::confused:
    I and another person have told you the problem with this. I can't spell it out anymore I'm afraid.


  • Closed Accounts Posts: 112 ✭✭gahim


    "The problem you have is that your database has 3 fields in it and you are only supplying 2 fields. There is a way to show which columns you want your 2 fields to match up to, ignoring the other field (if it is allowed to be null)."

    What do you mean by this? I want it to have 4 fields, and to login 2 fields is required...


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Then alter the table and add in those extra fields. Then when you've all your fields sorted, then do the insert with the appropriate values.


  • Advertisement
  • Closed Accounts Posts: 112 ✭✭gahim


    Is there somewhere with step by step instructions on how to add fields etc..?


Advertisement