Jump to content

jukie

Members
  • Posts

    24
  • Joined

  • Last visited

jukie's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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'); } ?>
×
×
  • 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.