Jump to content


VlexoFree Notice

Interviews will be open every Friday starting at 12am PDT and lasting for 24 hours.

- - - - -

login mysql


  • Please log in to reply
7 replies to this topic

#1 TheExposedOne

TheExposedOne

    Advanced Member

  • Pre-Members
  • 111 posts

Posted 15 July 2010 - 12:48 PM

hi,
how do you make a login and use an already made mysql table

i have a script that makes tables in mysql but would like another script the same tables in that same mysql database
Child - "Can I have some connective tissue Mom"
Mom - "Of course you can" *Hands over Standard Supermarket meat pie*

Again...


Child - "Shall I eat it, Shall I eat it"
Mom - "No it's disgusting!" *Throws Standard Supermarket meat pie out of childs hand*

Ad Bot


      #2 Eli L

      Eli L

        VlexoFree Owner

      • Owner
      • 6,950 posts
      • LocationWashington, USA

      Posted 15 July 2010 - 01:09 PM

      Moved to Web Dev

      Posted Image


      Please do not PM me for support (unless its a private matter). Instead, post in the appropriate forum and help will be provided accordingly.
      Helpful links: Terms of Service | Privacy Policy | Wiki - Tutorials & Help | VlexoFree Support |


      #3 Sharad D

      Sharad D

        Advanced Member

      • VlexoFree Support
      • 1,349 posts
      • LocationBengaluru, India

      Posted 15 July 2010 - 10:29 PM

      I didn't under stand the problem.... If you have username and passwords stored on server, just fetch entry from table and compare the passwords.

      With great power comes great responsibility

      Please do not PM me for support. Instead, post in the appropriate forum and help will be provided accordingly.
      Helpful links: Terms of Service | Privacy Policy | Wiki - Tutorials & Description | VlexoFree Support


      #4 TheExposedOne

      TheExposedOne

        Advanced Member

      • Pre-Members
      • 111 posts

      Posted 16 July 2010 - 05:32 AM

      id like a script that would do that for me
      Child - "Can I have some connective tissue Mom"
      Mom - "Of course you can" *Hands over Standard Supermarket meat pie*

      Again...


      Child - "Shall I eat it, Shall I eat it"
      Mom - "No it's disgusting!" *Throws Standard Supermarket meat pie out of childs hand*

      #5 Sharad D

      Sharad D

        Advanced Member

      • VlexoFree Support
      • 1,349 posts
      • LocationBengaluru, India

      Posted 16 July 2010 - 11:16 AM

      Structure of database is needed for that... Without that script can not be prepared... Explaining database structure in public may compensate security on your site. SO its better if you code it your self.

      Edited by System Sneaker, 16 July 2010 - 11:16 AM.

      With great power comes great responsibility

      Please do not PM me for support. Instead, post in the appropriate forum and help will be provided accordingly.
      Helpful links: Terms of Service | Privacy Policy | Wiki - Tutorials & Description | VlexoFree Support


      #6 seguy

      seguy

        Newbie

      • Pre-Members
      • 4 posts
      • LocationHongkong

      Posted 19 July 2010 - 07:28 PM

      u need to include a database check in php and connect the database to provide a login.

      #7 bossier330

      bossier330

        Newbie

      • Pre-Members
      • 4 posts

      Posted 15 December 2010 - 11:08 AM

      Here's a simple example for you to see basically how things work. Note that this is NOT a GOOD implementation. It is only meant to show you the basics.

      $db_host = 'host site';
      $db_user = 'user name';
      $db_pass = 'password';
      $db_name = 'database name';
      
      // Connect to the MySQL database and save the link identifier (false if unsuccessfull).
      $db_connection = mysql_connect($db_host, $db_user, $db_pass);
      
      // Select the database, explicitly specifying the above link identifier.
      mysql_select_db($db_name, $db_connection);
      
      // Capture the user name depending on your needs.
      $username = // Fill in here.
      
      // Build the query.
      $query = "SELECT * FROM `" . 'table name' . "` WHERE `" . 'user name column heading' . "` = '" . $username . "'";
      
      // Perform the query.
      $result = mysql_query($query);
      
      // Check for success with $result.
      
      // The following lines will return the stored password so that you can perform a check.
      $row = mysql_fetch_assoc($result);
      $row['password field name'];
      
      // Process the login...
      

      Untested, but it should work haha.

      #8 Kiro R

      Kiro R

        Advanced Member

      • VlexoFree Support
      • 426 posts

      Posted 15 December 2010 - 03:34 PM

      View Postbossier330, on 15 December 2010 - 11:08 AM, said:

      Here's a simple example for you to see basically how things work. Note that this is NOT a GOOD implementation. It is only meant to show you the basics.

      $db_host = 'host site';
      $db_user = 'user name';
      $db_pass = 'password';
      $db_name = 'database name';
      
      // Connect to the MySQL database and save the link identifier (false if unsuccessfull).
      $db_connection = mysql_connect($db_host, $db_user, $db_pass);
      
      // Select the database, explicitly specifying the above link identifier.
      mysql_select_db($db_name, $db_connection);
      
      // Capture the user name depending on your needs.
      $username = // Fill in here.
      
      // Build the query.
      $query = "SELECT * FROM `" . 'table name' . "` WHERE `" . 'user name column heading' . "` = '" . $username . "'";
      
      // Perform the query.
      $result = mysql_query($query);
      
      // Check for success with $result.
      
      // The following lines will return the stored password so that you can perform a check.
      $row = mysql_fetch_assoc($result);
      $row['password field name'];
      
      // Process the login...
      

      Untested, but it should work haha.

      It wouldn't work.
      Because you're not calling the actual form, which you can do two ways. A simple if statement or via isset(), which you didn't do at all.

      include "config.php"; //Include your configs from a file, not differently on each page
      if(isset($_POST['submitbutton'])){
      
      $username = mysql_real_escape_string($_POST['username']);
      $password = mysql_real_escape_string($_POST['password']);
      
      $GettingUser = mysql_query("SELECT * FROM `table` WHERE `Username`='$username' && `Password`='$password'") or die(mysql_error());
      $HasUser = mysql_fetch_assoc($GettingUser);
      
      if(!$username && !$password){ die("<script>alert('Fill in all fields');history.back('');</script>"); }
      if(mysql_num_rows($GettingUser) == 0){ die("<script>alert('Account doesn't exist');history.back('');</script>"); }
      
      //This is where it is successful.
      $_SESSION['user'] = $username;
      
      //From hereon out if the login was successful you can note if the user is logged in by using the $_SESSION['user'] variable, but you must add session_start(); and session_end(); if those are right, lmao I can't remember to the top and bottom of your page.
      
      }
      

      That is the correct way.
      Yours Sincerely,

      Kiro R.
      VlexoFree Support Team


      Please do not PM me for support. Instead, post in the appropriate forum and help will be provided accordingly.
      Helpful links: Terms of Service | Privacy Policy | Wiki - Tutorials & Description | VlexoFree Support |





      1 user(s) are reading this topic

      0 members, 1 guests, 0 anonymous users