-
retrieving information from database mysql
nevermind got it working
-
retrieving information from database mysql
I have created a form when user enters username and password it compares it against the mysql databse. The code for the php is written below. I have entered a username and password into the form and when i click login I am getting 'Invalid username or password' even though it is correct. Can some have a look at the code and tell me what I am doing wrong. All databse field names etc are all correct. thank you <?php $host = '***'; // Host name Normally 'LocalHost' $user = '***'; // MySQL login username $pass = '****'; // MySQL login password $database = '***'; // Database name $table = '****'; // Members name mysql_connect($host, $user, $pass); mysql_select_db($database); $username = mysql_real_escape_string($_POST['username']); $password = hash('sha512', $_POST['password']); $result = mysql_query("SELECT * FROM $table WHERE username = '$username' AND password = '$password' "); if(mysql_num_rows($result)) { // Login session_start(); $_SESSION['username'] = htmlspecialchars($username); // htmlspecialchars() sanitises XSS } else { // Invalid username/password echo '<p><strong>Error:</strong> Invalid username or password.</p>'; } // Redirect header('Location: http://www.****.com/loggedin.php'); exit; ?>
-
retrieving information from database mysql
thanks for your prompt reply. In the database i want to have 4 fields: unique ID, first name, surname, sport preference. I am going to enter the unique ID, first name & surnames into the mysql database. On the form on the website I have unique id ____ first name _____ Surname ______ Sport prefernce _____ I will be giving the user their ID so when they fill in the ID it will display their name and surname automatically (as its stored in the database so yes I want the unique ID to fetch the name. They then need to select their sports preference. Once thats done and click submit the sports preference is added to the field beside their name in the mysql database.
-
retrieving information from database mysql
hi, i have succesfully set up mysql & php so that when a user enters their name and sport preference it stores it in my mysql database. What i want to do now is enter all their names into a the mysql databse and assign each person a unique number. on the website when the person enters this unique number it would like it to auto fill their name in and all they need to do is select their sport. Any help would be appreciated <?php $con = mysql_connect("DBHOST","DBUSER","PASS") or die(mysql_error('Cannot connect')); mysql_select_db("DBUSER", $con); //Replace with your MySQL DB Name $firstname=mysql_real_escape_string($_POST['firstname']); //This value has to be the same as in the HTML form file $lastname=mysql_real_escape_string($_POST['lastname']); //This value has to be the same as in the HTML form file $sport=mysql_real_escape_string($_POST['sport']); //This value has to be the same as in the HTML form file $sql="INSERT INTO weddingtable (firstname,lastname,sport) VALUES ('$firstname','$lastname','$aport')"; /*form_data is the name of the MySQL table where the form data will be saved.name and email are the respective table fields*/ if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } header ('Location: **'); mysql_close($con); ?>
-
Creating a website with Multiple Logins Help
Hi, I am making a wedding website. There are two types of quests that are coming, those that are invited to the ceremony/recepetion and those that are only invited to reception. So a guest would login with a given username and password which would forward them to a RVSP page for either ceremony/reception or just reception depending upon the username and password they entered. Would anyone have any examples of codes that i could work from to get me started thanks
-
Creating a website with Multiple Logins Help
thanks for suggestions shall try php form
-
Creating a website with Multiple Logins Help
Hi, I want to create a website with 2 logins. I am making a wedding website. There are two types of quests that are coming, those that are invited to the ceremony/recepetion and those that are only invited to reception. So a guest would login with a given username and password which would forward them to a RVSP page for either ceremony/reception or just reception depending upon the username and password they entered. Has anyone any example of code that I could use to get the ball rolling so to speak. I will most likely need a PHP script and mysql which I have. Any help would be appreciated Thanks