Jump to content

Colourtheory

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by Colourtheory

  1. For some reason, it always says that the password is incorrect. I have looked at everything, so I'm hoping that someone can help me <? //This function will find and checks if your data is correct //Collect your info from login form $username = $_REQUEST['username']; $password = $_REQUEST['password']; //Connecting to database $connect = mysql_connect("myhost", "myuser", "mypass"); if(!$connect){ die(mysql_error()); } //Selecting database $select_db = mysql_select_db("mydatabase", $connect); if(!$select_db){ die(mysql_error()); } //Find if entered data is correct $result = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'"); $row = mysql_fetch_array($result); $id = $row['id']; $select_user = mysql_query("SELECT * FROM users WHERE id='$id'"); $row2 = mysql_fetch_array($select_user); $user = $row2['username']; if($username != $user){ die("Username is wrong!"); } $pass_check = mysql_query("SELECT * FROM users WHERE username='$username' AND id='$id'"); $row3 = mysql_fetch_array($pass_check); $email = $row3['email']; $select_pass = mysql_query("SELECT * FROM users WHERE username='$username' AND id='$id' AND email='$email'"); $row4 = mysql_fetch_array($select_pass); $real_password = $row4['password']; if($password != $real_password){ die("Your password is wrong!"); } //Now if everything is correct let's finish his/her/its login session_register("username", $username); session_register("password", $password); echo "Welcome, ".$username." please continue on our <a href=index.php>Index</a>"; ?>
  2. Colourtheory

    Error

    Ok, I added user ID's.
  3. Colourtheory

    Error

    How would you reccomend doing it? This is my first time setting up a login/register system and I have no idea how to go about doing it, so I'm being creative.
  4. Colourtheory

    Error

    Yes, that's the name. The error is here: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE ( Username varchar(15), Password varchar(15), Email varchar(15), A' at line 1
  5. Colourtheory

    Error

    How do I fix this error? I'm pasting the SQL part but if you need the PHP part ask. $acc = "CREATE TABLE $_POST[username](Username varchar(15),Password varchar(15),Email varchar(15),Age int)"
  6. I fixed it by adding a check box that only lets the script run if it's checked, thanks for the help guys!
  7. I'm just wondering if this is a good place for newbies, I am learning several languages, and have questions. Is this forum (not this section) only right for advanced people?
  8. Would adding NOT NULL to the values stop this?
  9. Oh, so even when it redirects it adds a record?
  10. I'm sending this post request. <form action="insert.php" method="post">Username:<br> <input class="register" type="text" name="username"><br>Lastname:<br> <input class="register" type="text" name="password"><br>Email:<br> <input class="register" type="text" name="email"><br>Age:<br><input class="register" type="text" name="age"<br><input type="submit"></form>
  11. It's not a public website I'm just trying to learn PHP and SQL.
  12. $con = mysql_connect(my sql information is here and works dont worry about that);if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("u486827913_accounts", $con); $sql="INSERT INTO Accounts (Username, Password, Email, Age)VALUES('$_POST[username]','$_POST[password]','$_POST','$_POST[age]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added"; mysql_close($con);?> </div></body>
  13. *Input box, it enters the users input and creates a SQL object with their information
  14. Colourtheory

    SQL Double

    I have a box "register" thing which simply inserts a new object into my MySQL table, and it works- BUT it also creates a spare one which is completely blank and has no values or anything. I can give the source, just ask if required.
×
×
  • Create New...