Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder kosstr12's Avatar
    Join Date
    Apr 2007
    Location
    Woodstock, Georgia
    Posts
    428
    Thanks
    7
    Thanked 5 Times in 5 Posts

    Why wont my login work? =[

    I got an online tutorial on how to creat a php login thing. And for some reason i cant get it to work, i'll give you all a pic of my database name, and see if you can help me connect to it.




    This is the code im using to connect, but i think my database name is wrong( Please tell me how to fix the name also):
    Code:
    <?
    // Replace the variable values below
    // with your specific database information.
    $host = "";
    $user = "";
    $pass = "";
    $db   = "";
    // This part sets up the connection to the 
    // database (so you don't need to reopen the connection
    // again on the same page).
    $ms = mysql_pconnect($host, $user, $pass);
    if ( !$ms )
    {
    echo "Error connecting to database.\n";
    }
    // Then you need to make sure the database you want
    // is selected.
    mysql_select_db($db);
    ?>
    Code:
    also, this is the register page im using, any ideas on how to improve this:
    <?php
    // dbConfig.php is a file that contains your
    // database connection information. This
    // tutorial assumes a connection is made from
    // this existing file.
    include ("dbConfig.php");
     
    //Input vaildation and the dbase code
    if ( $_GET["op"] == "reg" )
     {
     $bInputFlag = false;
     foreach ( $_POST as $field )
      {
      if ($field == "")
       {
       $bInputFlag = false;
       }
      else
       {
       $bInputFlag = true;
       }
      }
     // If we had problems with the input, exit with error
     if ($bInputFlag == false)
      {
      die( "Problem with your registration info. "
       ."Please go back and try again.");
      }
     // Fields are clear, add user to database
     //  Setup query
     $q = "INSERT INTO `dbUsers` (`username`,`password`,`email`) "
      ."VALUES ('".$_POST["username"]."', "
      ."PASSWORD('".$_POST["password"]."'), "
      ."'".$_POST["email"]."')";
     //  Run query
     $r = mysql_query($q);
     
     // Make sure query inserted user successfully
     if ( !mysql_insert_id() )
      {
      die("Error: User not added to database.");
      }
     else
      {
      // Redirect to thank you page.
      Header("Location: register.php?op=thanks");
      }
     } // end if
     
    //The thank you page
    elseif ( $_GET["op"] == "thanks" )
     {
     echo "<h2>Thanks for registering!</h2>";
     }
     
    //The web form for input ability
    else
     {
     echo "<form action=\"?op=reg\" method=\"POST\">\n";
     echo "Username: <input name=\"username\" MAXLENGTH=\"16\"><br />\n";
     echo "Password: <input type=\"password\" name=\"password\" MAXLENGTH=\"16\"><br />\n";
     echo "Email Address: <input name=\"email\" MAXLENGTH=\"25\"><br />\n";
     echo "<input type=\"submit\">\n";
     echo "</form>\n";
     }
    // EOF
    ?>


    EDIT: I can now connect to my Database but it still says "User not entered into database" I think I'm telling it to enter the user in the wrong table or whatever.




    Thanks so much,
    koss
    Last edited by kosstr12; 02-14-2008 at 10:54 PM.

  • #2
    Banned
    Join Date
    Feb 2008
    Location
    Winnipeg, Canada
    Posts
    396
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Posting your database ip/user/pass is a BAD idea.

    Where is your login code? I only see register and connect.

  • #3
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts
    like he said, it's a bad idea...

    but my thought is.. if you are using MySQL... it takes the name of your account (Say you signed up with michael) and it attaches that to like... everything.

    So it'd be michael_loginthingy or michael_dbuser


    try that

  • #4
    Regular Coder kosstr12's Avatar
    Join Date
    Apr 2007
    Location
    Woodstock, Georgia
    Posts
    428
    Thanks
    7
    Thanked 5 Times in 5 Posts
    Fixed the problem guys, thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •