Jump to content

Laurent*

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by Laurent*

  1. It didn't work, at least not without an error. I thought about most of the night and remembered something I found called "fetch_assoc()". Combined with ingolme bit I managed to get the page working to the minimal requirements. Although I'll have a bit of time before the next project after this is completely completed, it appears security might be apart of my later assignments. There is still more to do, Thank you all. <!DOCTYPE html> <html> <head> <title>Verifies login request</title> </head> <body> <h1>Please wait to be redirected to the appropriate page</h1> <?php $servername = "..........."; $username = ".............."; $password = "..............."; $database = "......................."; //Testing search terms $testUsername = $_POST['uname']; $testPassword = $_POST['psw']; $testTitle; $testTable = "users"; $pagelocation = "LoginPage.php"; // Create connection $conn = new mysqli($servername, $username, $password, $database); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $query = " SELECT username, password, title FROM $testTable WHERE username = '$testUsername' AND password = '$testPassword'"; //$result = $conn->query($query); $result=mysqli_query($conn,$query); if ($result->num_rows > 0) { //$row = $result->fetch_row(); $row = mysqli_fetch_assoc($result); //Print the right message and set the right destination switch ($row["title"]) { case "admin": $pagelocation = "AdminSettingPage.php"; //Send the user to the admin page echo "Sending you to settings page now. "; break; case "teacher": $pagelocation = "TeacherSettingPage.php"; //Send the user to the admin page echo "Sending you to settings page now. "; break; } } else { echo"I'm sorry, your user & password does not exist. Please go away......"; $pagelocation = "LoginPage.php"; } mysqli_free_result($result); mysqli_close($conn); ?> <!--Send the user where they suppose to go--> <a href=></a> <meta http-equiv="Refresh" content="5;url=<?php echo $pagelocation; ?>"> </body> </html>
  2. I really don't have any idea what I can do. All I want is the "title" of the user who password and username match my query/search/ect. I looked at "prepared statements" on w3 but it just an insert example and my initial problem was getting results. I even changed the array but I'm not getting anything from it. I don't know what the title of the user is and I want to figure out. How can I get the data? This is the Here what I'm thinking. Getting upset but still persisting. Be back early tomorrow I need to cool down and think. <!DOCTYPE html> <html> <head> <title>Verifies login request</title> </head> <body> <h1>Please wait to be redirected to the appropriate page</h1> <?php $servername = "localhost"; $username = "root"; $password = "TheMango0*"; $database = "betacode_database"; //Testing search terms $testUsername = $_POST['uname']; $testPassword = $_POST['psw']; $testTitle; $testTable = "users"; $pagelocation = "LoginPage.php"; // Create connection $conn = new mysqli($servername, $username, $password, $database); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //I can't figure out how to use this. /*$stmt = $conn->prepare("INSERT INTO MyGuests (firstname, lastname, email) VALUES (:firstname, :lastname, :email)"); $stmt = $conn->prepare("SELECT FROM $testTable (username, password, title) VALUES (:username, :password, :title)"); $stmt->bindParam(':username', $testUsername); $stmt->bindParam(':password', $testPassword); $stmt->bindParam(':title', $testTitle);*/ $query = " SELECT username, password, title FROM $testTable WHERE username = '$testUsername' AND password = '$testPassword'"; $result = $conn->query($query); $row = mysqli_fetch_row($result); if ($result->num_rows > 0) { //$row = $result->fetch_row(); switch ($row[6]) { case "admin": $pagelocation = "AdminSettingPage.php"; break; case "teacher": $pagelocation = "TeacherSettingPage.php";break; } //Send the user to the admin page echo "Sending you to settings page now. "; mysqli_free_result($result); } else { //Send the user back to the login page. echo "I'm sorry, your user & password does not exist. Please go away......"; //$pagelocation = "LoginPage.php"; } // Perform queries //mysqli_query($conn,"SELECT * FROM users WHERE"); //mysqli_query($con,"INSERT INTO Persons (FirstName,LastName,Age) //VALUES ('Glenn','Quagmire',33)"); mysqli_close($conn); ?> <!--Send the user where they suppose to go--> <a href=></a> <meta http-equiv="Refresh" content="5;url=<?php echo $pagelocation; ?>"> </body> </html>
  3. Well one problem is solved but the thread still isn't done. I tried on my own but it not working. I think my problem is with the array because the switch case never works. <!DOCTYPE html> <html> <head> <title>Verifies login request</title> </head> <body> <h1>Please wait to be redirected to the appropriate page</h1> <?php $servername = "............."; $username = "..............."; $password = ".............."; $database = ".............."; //Testing search terms $testUsername = $_POST['uname']; $testPassword = $_POST['psw']; $testTable = "users"; $pagelocation = "LoginPage.php"; // Create connection $conn = new mysqli($servername, $username, $password, $database); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $query = " SELECT username, password FROM $testTable WHERE username = '$testUsername' AND password = '$testPassword'"; $result = $conn->query($query); $row = mysqli_fetch_row($result); if ($result->num_rows > 0) { switch ($row["title"]) { case "admin": $pagelocation = "AdminSettingPage.php"; break; case "teacher": $pagelocation = "TeacherSettingPage.php";break; } //Send the user to the admin page echo "Sending you to settings page now. "; mysqli_free_result($result); } else { //Send the user back to the login page. echo "I'm sorry, your user & password does not exist. Please go away......"; //$pagelocation = "LoginPage.php"; } mysqli_close($conn); ?> <!--Send the user where they suppose to go--> <a href=></a> <meta http-equiv="Refresh" content="5;url=<?php echo $pagelocation; ?>"> </body> </html>
  4. How is this? It not stupid code right? <?php $servername = "..."; $username = "..."; $password = "..."; $database = "..."; //Testing search terms $testUsername = "G. mane"; $testPassword = "wrap"; $testTable = "users"; // Create connection $conn = new mysqli($servername, $username, $password, $database); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $query = " SELECT username, password FROM $testTable WHERE username = '$testUsername' AND password = '$testPassword'"; $result = $conn->query($query); if ($result->num_rows > 0) { //FOUND YOU! echo "I Found a user"; } else { echo "User name and password did not match or does not exist"; } // Perform queries //mysqli_query($conn,"SELECT * FROM users WHERE"); //mysqli_query($con,"INSERT INTO Persons (FirstName,LastName,Age) //VALUES ('Glenn','Quagmire',33)"); mysqli_close($conn); ?>
  5. Hello, I'm trying to create a user login page by going through a SQL database and finding if a user exist in the users table. After that I need to decide what page to send the user to either the admin page or the student page. I tried looking through w3 but this was the closes example I found. https://www.w3schools.com/php/php_mysql_select.asp What's been done so far Login page HTLM Connection test to the data base success Data Base created Users table created 1 admin and 1 student have been populated in the users table
  6. I failed this assignment but I thrived in the next one which was worth more. Anyways the professors code examples aren't good and I decided to stop using the resources. This is why I struggled because I thought I needed to use his examples and I had a different SQL with different syntax. I was trying to create a data base named chinese_zodiac. This thread is done.
  7. I've looked through this and I still don't understand. I don't even what i'm creating honestly. I'm just trying to fix an error.
  8. Hey, I need to create a database and tables. I'm using phpmyadmin to do this. According to the professor's Power point slides the code below should create a table however it got me an error. I don't know how to think about this yet so go easy on me please. CREATE TABLE zodiacsigns (Sign VARIABLES(10), President VARIABLES(75));
  9. Wow thanks, this solution is spot on Dsonesuk! <3
  10. I have a issue and there might be multiple ways to solve it. I want a button to reveal extra content when it is clicked. I want to slide the extra content in from the left using the w3.animations or any other method that would be easy to follow and have it stop in the center of the screen. The content is a image and a few words describing it in a organized container. How would I do this or do you have any general advice for me to follow?
  11. It was locked. I guess this is a mission accomplished....
  12. I'm working in java script and I'm having a hard time finding my error. My error started with a var named fx. fx is a math expression and I was sure I did everything correctly but I don't know. fx is a representation of the math expression below. Please help me fix this syntax error. var xcoord = 0; var ycoord = 100; var degreeOfRotation = 0; var degree = (-degreeOfRotation *Math.PI)/180; var smoother = 10; var tipAdjuster = 2.8; var innerDisplacement = -3; var fx =( smoother * Math.pow ( ( ( (-ycoord*Math.sin(degree))+(-xcoord*cos(degree))-xcoord) + xcoord ) , tipAdjuster ) )
  13. Introduction I want to standardize my approach to building a css style sheet and the way I use my classes in my HTML. I download the w3 architect template along with w3 css style sheet. I've made edits to the HTLM page to my personalize agenda but I'm unsure how to personalize the css file. From my research looking around the web while I waited for approval, I noticed the w3 css style sheet might be badly written due to how often the !important operator is used, and a few naming problem. I'm very unsure what is right and what is wrong. I have 2 primary goals I want to accomplish. 1st: How should I structure the classes in my css? 2nd: How should I apply styles in the html file? Goals I've learned there are many ways to structure classes in css. http://stackoverflow.com/questions/5196583/target-elements-with-multiple-classes-within-one-rule/7270033#7270033 What would be the best method for structuring class? Which classes should have children? Should one item have multiple classes and if so how many? Regarding the html part of my personal project I've done some experimenting. I noticed classes being override. I tested multiple conditions and I came to conclusion I should have a process so I get exactly what I want with no override. When I mean process I meant the process of applying style. The example below shows I want to apply styles in a step by step fashion. .I fear I might not be covering enough considerations which is why I want determine a routine process for applying any styles. Example: Step 1) Align object -> (Step 2) Determine font -> (Step 3) color ->(Step 4) ect Any advice?
×
×
  • Create New...