Jump to content

jukie

Members
  • Posts

    24
  • Joined

  • Last visited

Everything posted by jukie

  1. Sorry, I have sorted it out, I seen the error right away after reading the post, it was the hash part $Password = md5($pword); its should have been password not pword, don't know why I couldn't see this in the editor tho. sorry
  2. Hi I have developed a register form and a login form, register form is working but the login form is not working. login form. The login check just takes me back to the index page instead of mybookmarks.php. Can anyone see the issue in these codes? <form id="form1" action="logincheck.php" id="op" method="post"> <fieldset> <legend>Get On This Login</legend> <input type ="hidden" name="submitted" id="submitted" value="1"/> <label for='Username' >UserName</label> <input type='text' name='Username' id='Username' maxlength="50" /> <label for='Password' >Password</label> <input type='password' name='Password' id='Password' maxlength="50" /><br> <input type='submit' name='Submit' value='Login' /> </fieldset> </form> logincheck.php <?php session_start(); // dBase file include "connection.php"; // Inialize session session_start(); // Include database connection settings // Retrieve username and password from database according to user's input $login = mysql_query("SELECT * FROM members WHERE (Username = '" . mysql_real_escape_string($_POST['Username']) . "') and (Password = '" . mysql_real_escape_string(md5($_POST['Password'])) . "')"); // Check username and password match if (mysql_num_rows($login) == 1) { // Set username session variable $_SESSION['Username'] = $_POST['Username']; // Jump to secured page header('Location: mybookmarks.php'); } else { // Jump to login page header('Location: index.php'); } ?> I have added the register connection incase this can help solve the issue // dBase file include "connection.php"; //retrieving data from form $Username =$_POST ['Username']; $emailaddress =$_POST ['emailaddress']; $FirstName = $_POST ['FirstName']; $Password =$_POST ['Password']; //Protect from SQL Injection $Username = mysql_real_escape_string($Username); $emailaddress = mysql_real_escape_string($emailaddress); $FirstName= mysql_real_escape_string($FirstName); $Password = mysql_real_escape_string($Password); //hash the password $Password = md5($pword); $query = "INSERT INTO members( Username, Password, emailaddress, FirstName) VALUES ('$Username', '$Password','$emailaddress', '$FirstName')"; $sucess = mysql_query($query); if ($sucess) header("Location: index.php"); mysql_close($conn); Thank you for reading.
  3. Thanks, its does look like it got a unique constraint, struggling to drop it. Google my friend.
  4. Hello Good Evening/Morning/Afternoon where ever you are. My problem of the day I have created a register form, the form is working unless I use a data that already stored in the database for a different member, this is the password textbox of the form. Now the database for password is not unique. The problem could be the md5 hash I used for hashing the password. Maybe myphp admin will not allow duplicate data for md5. Any thoughts.
  5. jukie

    Delete Function

    Tried it with no quoted and still no success.
  6. Hello I'm trying to allow the user to delete a record from a web app. I copied a tutorial on deleting data but struggling to work it out. My php code is The ID in the final row is the id of the record (members) (this could be the issue) deletebookmark.php code <?php include "connection.php"; $order = "DELETE FROM "members" WHERE "" ='$ID'"; mysql_query($order); header("location:member.php"); ?>
  7. I had to change the code over due to it not working on go daddy, I've found a free hosting which allowed my code to work on their server, the database names were changed on purpose. But you are right, I do need to slow down and sort out issue by issue.
  8. I've just signed up with free hosting just to test the local code and it works. Crazy stuff.
  9. which provider do you recommend? I would rather my first code worked on go daddy to be honest.
  10. I can login in now, had to change the code from what worked in local to this local code $login = mysql_query("SELECT * FROM members WHERE (Username = '" . mysql_real_escape_string($_POST['Username']) . "') and (Password = '" . mysql_real_escape_string(md5($_POST['Password'])) . "')"); // Check username and password match if (mysql_num_rows($login) == 1) { // Set username session variable $_SESSION['Username'] = $_POST['Username']; // Jump to secured page header('Location: sucess.php'); } else { // Jump to login page header('Location: index.php'); } Live Server code $Username = mysql_real_escape_string($Username); $Password = mysql_real_escape_string($Password); $login ="SELECT * FROM gotusers WHERE username='$Username' and password= '$Password'"; $result=mysql_query($login); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ But this new code just brings new problems such as sessions as they were working on the local code. What is annoying is that even the registration page that worked in local doesn't work when uploaded. I have been working on PHP 5.4 and go daddy is using 5.3, Don't know if that is the issue. Pain in the bum.
  11. Thanks, I got the login in by changing the query. What is annoying me is that I had all this working in local, the register page is not even working either, or the sessions, now uploaded it to web and none of it working. Seems there no point in working locally if the codes don't work when uploaded to a web hosting. How can I avoid this in future, create identical environments
  12. Hi I posted this in another forum but this might be better in here, I just cant seem to get my login to check the username and password to let the user enter the webpage I get no errors, just that the index pages keeps reloading on submit. This is my MySQL code <?php $host = ''; $user = ''; $password = ''; $database = ''; $conn = mysql_connect($host,$user,$password) or die('Server Information is not Correct'); mysql_select_db($database,$conn) or die('Database Information is not correct'); // Inialize session session_start(); // Include database connection settings // Retrieve username and password from database according to user's input $login = mysql_query("SELECT * FROM gotusers WHERE (Username = '" . mysql_real_escape_string($_POST['Username']) . "') and (Password = '" . mysql_real_escape_string(md5($_POST['Password'])) . "')"); // Check username and password match if (mysql_num_rows($login) == 1) { // Set username session variable $_SESSION['Username'] = $_POST['Username']; // Jump to secured page header('Location: sucess.php'); } else { // Jump to login page header('Location: index.php'); } ?>
  13. Hope someone can help with this, its driving me mad. The database connections are correct. Now I've put it down to the query that is being used. Now this query worked in local. It would be easier if it produce an error but it just reloading the index page. I've even just changed the engine using this query. ALTER TABLE tablename ENGINE = INNODB and it didn't sort it.
  14. Its seems to be linked to this error Parse error: syntax error, unexpected T_STRING in D:\Hosting\10624400\html\logincheck.php on line 5 which is my password for the database, and the password is correct line 5 is $password = 'xxxxxxxx' Ive just fixed the above error , it was just a coma missing but now just reloading the index.php page. Must be the query.
  15. I now get no error and the login process does nothing, just keeps reloading the index page here the full code of the login check <?php session_start(); // dBase file include "connection.php"; $host = ''; $user = ''; $password = ''; $database = ''; $conn = mysql_connect($host,$user,$password) or die('Server Information is not Correct'); mysql_select_db($database,$conn) or die('Database Information is not correct'); // Inialize session session_start(); // Include database connection settings // Retrieve username and password from database according to user's input $login = mysql_query("SELECT * FROM gotusers WHERE (Username = '" . mysql_real_escape_string($_POST['Username']) . "') and (Password = '" . mysql_real_escape_string(md5($_POST['Password'])) . "')"); // Check username and password match if (mysql_num_rows($login) == 1) { // Set username session variable $_SESSION['Username'] = $_POST['Username']; // Jump to secured page header('Location: sucess.php'); } else { // Jump to login page header('Location: index.php'); } ?>
  16. Thank you for your reply. what is the best way of dealing with this to prevent this from happening. I'm using Go Daddy for hosting and its not quite as simple for me for editing on the go. When I choose to view/edit the file and its gives me notepad, I've tried to change the editor to net beans but struggling. What is the best process for a smooth transition from locally to web hosting. I'm getting an error which is in the login process Parse error: syntax error, unexpected T_STRING in D:\Hosting\10624400\html\logincheck.php on line 7 Line 7 is session_start(); Not much to go on
  17. Hi, I developed a practise website so I can learn databases. I created a login system and when the user logged in, the PHP would welcome the user by using their username using sessions, now this worked perfect for me locally, so I uploaded the site to a web hosting, change the database settings and created new databases. When I try to login, its just keeps loading the login page and nothing happening. The database settings and queries are correct. If it worked locally, shouldn't this work on web hosting. I'm not sure on how to tackle this issue.
  18. I would rather use User Id as it will be much easier then asking users for unique usernames. But how would I collect the id number of the user, i'm collecting the username from the login process. Do you understand my question as i'm not good at explaining myself.
  19. Thanks CDP, I got it working now Just changed it to unique username instead of User ID. Just made more sense to me. Just need to work on my css skills for pretty tables.
  20. The name is nothing to do with the user id (the name is the headline for the comment). Thanks for the tips, my session id is the username and not the ID and the username are not unique so maybe I should make the username unique.
  21. I have two tables, the first table primary key is UserID , in my second table I have UserID so struggling to link these up User ID (Primary Key) First Name Email Username Password Table 2 (User Comments) ID (Primary key) Name Comment User ID (Foreign key) Now I can login with different usernames and a passwords and when I post a comment, Table 2 User ID remains blank, instead of being filled with the User ID from table 1 (whoever the user is) This is my query in the php web page (second table) $selected = mysql_select_db("gotmembers", $connection) or die ("could not connect to mycomments"); $Name = $_POST['Name']; $Comment= $_POST['Comment']; $query = "INSERT INTO mycomments ( Name, Comment, ) VALUES ('$Name', '$Comment')"; $sucess = mysql_query($query); if ($sucess) echo '<script type="text/javascript">window.location.href="sucess.php";</script>' how do I insert the UserID of the user into this query.
  22. Thanks for explaining how the process works. At the moment I am using the username in the Session, should I be using the id of the profile in the session? As the ID of the user is linked to another table with information that needs to be displayed.
  23. Thanks for replying, yeah I got my words wrong, I have created 3 tables in one database and want to use the three tables on the individual page. I came on here just to point me in the right away as there is thousands of articles and I wasn't sure what to look for, I was stuck on keyword for google to search the right tutorials.
  24. Hi I'm a beginner in PHP, anyway i'm designing a website with membership, and I've created a register form and also a login, I can login and have used sessions so I can recall the username and create individual pages for each user. My next challenge is I want every user to have their own personal details stored on their individual page, the details are stored in a another database. My question Is how to link the sessions of the users to personal databases which are created in MySQL let me explain more. the user logged in welcome page the session will be called load up personal details from a second database Now I would need to link up another database to the members database using their ID key Members ID -Primary Key The second Database stuff will be inserted in this this will have to link up to the members database Now I'm not looking for an answer from you on how to do this, just recommend on what tutorials I should be following, and where to find more details on doing this.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.