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
245

Comments

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


    There is if you searched google:

    http://www.google.ie/search?hl=en&source=hp&q=adding+column+to+table+mysql&btnG=Google+Search&meta=&aq=f&oq=

    2nd result.

    Why are you so obsessed with step by step. There is no such thing as step by step as pointed out before. You need to read and learn and apply it to your own problem. Not every problem is identical.


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


    gahim wrote: »
    Is there somewhere with step by step instructions on how to add fields etc..?

    As I posted about 30 minutes ago:
    Tom Dunne wrote: »

    Seriously, you need to read what we are telling you.


  • Closed Accounts Posts: 112 ✭✭gahim


    Hi,

    Thanks for your help, I am new to my SQL, could you tell me, I have to add two columes and then add the field in each colume?

    Thanks Again


  • Closed Accounts Posts: 112 ✭✭gahim


    ALTER TABLE users ADD email VARCHAR(60);

    ALTER TABLE users ADD title VARCHAR(60);

    Is that what I should put?

    Thanks


  • Registered Users Posts: 8,584 ✭✭✭TouchingVirus


    gahim wrote: »
    So can someone give me a useful link instead of giving out to me?

    We're not here to give you links, that is google's job. We are here to help when you show us code, and say it's not working despite you researching X, Y and Z methods to fix it.


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


    gahim wrote:
    ALTER TABLE users ADD email VARCHAR(60);

    ALTER TABLE users ADD title VARCHAR(60);

    Is that what I should put?

    Thanks
    Probably. Give it ago and see if it's what you want. You can delete them after.

    I've a feeling you are simply not reading tutorials but jumping to code and inserting it hoping that it work. You need to read a bit more.


  • Registered Users Posts: 8,584 ✭✭✭TouchingVirus


    gahim wrote: »
    ALTER TABLE users ADD email VARCHAR(60);

    ALTER TABLE users ADD title VARCHAR(60);

    Is that what I should put?

    Thanks

    Back up your SQL database, run it and see where it leads :) Try the code first


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


    gahim wrote: »
    "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...
    add in the 4th field so. and you can have 20 fields but still only use the 2 for login. thats irrelevant.

    when you register, you insert a new row of data to your database, usually the full 4 items.
    when you login, you only to need to read (select) the fields of the row you need, username and password.


  • Closed Accounts Posts: 112 ✭✭gahim


    Yesss it works!

    Now its registration


  • Closed Accounts Posts: 112 ✭✭gahim


    Hi,
    I have created a form beta.gahim.com/start/index.php form is set POST to register.php, I have created register.php but don't know what to put inside...


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


    gahim wrote: »
    Hi,
    I have created a form beta.gahim.com/start/index.php form is set POST to register.php, I have created register.php but don't know what to put inside...

    That question has already been answered several times over in this thread.
    Evil Phil wrote: »
    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.
    CuLT wrote: »
    add in the 4th field so. and you can have 20 fields but still only use the 2 for login. thats irrelevant.

    when you register, you insert a new row of data to your database, usually the full 4 items.
    when you login, you only to need to read (select) the fields of the row you need, username and password.
    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: 1,181 ✭✭✭ronkmonster


    Ok, if your form is set to send data to register.php

    setup your register.php to assign those 4 values to variables and output them to page.

    post that code here and i'll help you with next stage.


  • Registered Users Posts: 8,584 ✭✭✭TouchingVirus


    Ok, if your form is set to send data to register.php

    setup your register.php to assign those 4 values to variables and output them to page.

    post that code here and i'll help you with next stage.

    This is for a BT Young Scientist project, I do hope you won't be holding the OP's hand because you're not getting the award if they win :D


  • Closed Accounts Posts: 112 ✭✭gahim


    Hi Guys,
    Sorry, I did everything on http://www.trap17.com/index.php/simple-php-login-registration-system_t52533.html

    to be more specific

    I have login2.php which contains
    <?php
    include 'mysql-connect.php';

    $username = $_POST;
    $password = $_POST;
    $query1 = mysql_query("SELECT * FROM users WHERE username='$username'");
    $result = mysql_num_rows($query1);
    if($result == 0)
    {
    include '<h1>Sorry!</h1>The username you specified does not exist!';
    }
    else
    {

    $checkuser = mysql_query("SELECT * FROM users WHERE username='$username'");

    $row = mysql_fetch_array($checkuser);
    $password2 = $row;
    $status = $row;
    if ($password == $password2)
    {
    Location: http://beta.gahim.com/Builder
    }
    else
    {
    echo '<h1>Error!</h1>The username and password combination you entered does not match the ones we have in our database.';
    }

    }
    ?>



    register.php

    <?php
    include 'mysql-connect.php';
    $username = $_POST;
    $password = $_POST;
    $name = $_POST;
    $email = $_POST;
    $title = $_POST;

    $result = mysql_num_rows(mysql_query("SELECT * FROM TABLENAME WHERE username='$username'"));
    if($result == 1)
    {
    echo ‘<h1>ERROR!</h1>Ah Sorry, that username is not available!’;
    }
    else
    {
    mysql_query("INSERT INTO TABLENAME (username, password, name, email, title)
    VALUES ('$username', '$password', '$name', '$email', 'title')");

    echo '
    <p>Cool, you now have a website!</p>
    <p><a href="login.php">Click here</a> to login and start building!</p>‘;
    ?>

    mysql-connect.php

    <?php
    $con = mysql_connect("localhost","gahimcom_gahim","---mypasswordhere---");
    mysql_select_db("gahimcom_members", $con);
    ?>

    beta.gahim.com/start

    If you go to the page you will see the form code


    I am doing something wrong as it doesn't work...

    I think it's the location:beta.gahim.com/builder

    (the success page)


  • Closed Accounts Posts: 112 ✭✭gahim


    gahim wrote: »
    Hi Guys,
    Sorry, I did everything on http://www.trap17.com/index.php/simple-php-login-registration-system_t52533.html

    to be more specific

    I have login2.php which contains
    <?php
    include 'mysql-connect.php';

    $username = $_POST;
    $password = $_POST;
    $query1 = mysql_query("SELECT * FROM users WHERE username='$username'");
    $result = mysql_num_rows($query1);
    if($result == 0)
    {
    include '<h1>Sorry!</h1>The username you specified does not exist!';
    }
    else
    {

    $checkuser = mysql_query("SELECT * FROM users WHERE username='$username'");

    $row = mysql_fetch_array($checkuser);
    $password2 = $row;
    $status = $row;
    if ($password == $password2)
    {
    Location: http://beta.gahim.com/Builder
    }
    else
    {
    echo '<h1>Error!</h1>The username and password combination you entered does not match the ones we have in our database.';
    }

    }
    ?>



    register.php

    <?php
    include 'mysql-connect.php';
    $username = $_POST;
    $password = $_POST;
    $name = $_POST;
    $email = $_POST;
    $title = $_POST;

    $result = mysql_num_rows(mysql_query("SELECT * FROM TABLENAME WHERE username='$username'"));
    if($result == 1)
    {
    echo ‘<h1>ERROR!</h1>Ah Sorry, that username is not available!’;
    }
    else
    {
    mysql_query("INSERT INTO TABLENAME (username, password, name, email, title)
    VALUES ('$username', '$password', '$name', '$email', 'title')");

    echo '
    <p>Cool, you now have a website!</p>
    <p><a href="login.php">Click here</a> to login and start building!</p>‘;
    ?>

    mysql-connect.php

    <?php
    $con = mysql_connect("localhost","gahimcom_gahim","---mypasswordhere---");
    mysql_select_db("gahimcom_members", $con);
    ?>

    beta.gahim.com/start

    If you go to the page you will see the form code


    I am doing something wrong as it doesn't work...

    I think it's the location:beta.gahim.com/builder

    (the success page)

    I don't know what you mean, I have set the variables and output page, could someone confirm the sulfess page code is right as I wrote that myself. :)


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


    This is for a BT Young Scientist project, I do hope you won't be holding the OP's hand because you're not getting the award if they win :D

    just helping to show how to develop an idea. build up from smaller parts.

    first stage make sure you getting the right data across.

    OP from your code, put an echo 'test'; in your code start near top and work down until it doesn't appear anymore. your problem is between the working echo and the non-working one.


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


    gahim wrote: »
    I don't know what you mean, I have set the variables and output page, could someone confirm the sulfess page code is right as I wrote that myself. :)

    Its not the builder page. it doesn't move from the login2.php page

    do the echo thing from my last post. php doesn't display stuff if even small thing is wrong

    put echo 'test'; after
    include 'mysql-connect.php';


  • Closed Accounts Posts: 112 ✭✭gahim


    Put <?php
    echo "test";?> on the top of which page? login2.php


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


    yes

    when you try login, look at the address bar and you can see that address is still login2.php

    that means it didn't get transferred to next page. so problem is probably before that part


  • Closed Accounts Posts: 112 ✭✭gahim


    I have gone to page after page and read everything, done everything and it doesn't work!

    I have explained whats on my page, what do you mean by putting this echo test on the page, how will that help?

    Again I would like to thank everyone for there help, I am new to databases, in fact 3 days ago I didn't even know what a database was...


  • Advertisement
  • Registered Users Posts: 35,524 ✭✭✭✭Gordon


    Is this latest problem the problem you were experiencing in this thread? I gave up on that thread after it turned out you weren't listening to people and weren't providing source code and you were jumbling up what html was on the website compared with what code you were posting.


  • Closed Accounts Posts: 112 ✭✭gahim


    Of course I am listening to people, but it's so confusing and stressful....

    Nothing I do works....

    :(
    :confused:


  • Closed Accounts Posts: 112 ✭✭gahim


    Hi,
    I gave the HTML and PHP codes in my previous posts...

    Shall I just give up?


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


    putting echo up near the top will show output if its working. if some of the following code which doesn't output doesn't work, you wouldn't know about it

    so if echo works near the top, move it down a few lines and try again. repeat until it doesn't

    either that or remove the bulk of the code and add the code back in parts until it stops working

    so your choice is either of the above or reread your code over and over until your spot something. which is unlikely since you're new to this.


  • Closed Accounts Posts: 112 ✭✭gahim


    Ok,
    So what is the echo test code?


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


    echo 'test';


  • Closed Accounts Posts: 112 ✭✭gahim


    I have ran the test and there was no difference in any of the pages

    http://beta.gahim.com/start/login2.php - Login Action
    http://beta.gahim.com/start/register.php - Registration
    http://beta.gahim.com/start/mysql-connect.php - Connection Code from form to sql
    http://beta.gahim.com/start/index.php - Signup Page


  • Closed Accounts Posts: 112 ✭✭gahim


    Hi I will just start everything over....


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


    That question has already been answered several times over in this thread.
    You forgot me :)
    Webmonkey wrote:
    A register would be an insert statement.


  • Advertisement
  • Closed Accounts Posts: 112 ✭✭gahim


    Hi Everyone,
    I deleted everything I had done and started from scratch, using http://www.trap17.com/index.php/phpmysql-loginregister_t9487.html I did it but (as you may have guessed) it doesn't work, :(

    Can anyone recommend a link that can help me with login/registration linking to mysqldatabase, I did a search on Google and used 3.

    The only one that worked was http://www.howtodothings.com/computers-internet/how-to-make-a-login-system-for-your-website#comment-8341 BUT it had no registration form instructions.


Advertisement