Jump to content

Metorium

New Members
  • Posts

    3
  • Joined

  • Last visited

Metorium's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey barand thank you for helping me I am a college student and i want to do website production when im older. I learnt HTML at school but want to try and teach myself some PHP You said i need to define the host, how do i go about doing that? also i am useing 000webhost at the moment (not permanent) and i dont think they support mysqli
  2. I am trying to create a log in page but all that comes up is Please enter a username and password <?php session_start () ; $username = $_POST ['username'] ; $password = $_POST ['passowrd'] ; if ($username&&$password) { define ('DB_HOST' , 'localhost') ; define ('DB_USER' , 'root') or die ("Could not connect!") ; define ('DB_PASSWORD', "") or die ("Could not find DB!") ; define ('DB_DATABASE', 'joke') ; } else die ("Please enter a username and password") ; $query = mysql_query ("SELECT * FROM Joke WHERE username = '$username'") ; $numrow = mysql_num_rows ($query) ; if ($numrows!=0) { //code to login While ($row= mysql_fetch_assoc($query)) { $dbusername = $row ['username'] ; $dbusername = $row ['password'] ; } //check if they match if ($username==$dbusername&&$password==$dbpassword) { echo "You're inn! <a href=member.php> Click here to enter member page" ; $_SESSION['username']=$dbusername ; } else echo "incorrect password!" ; } else die("That user does'nt exist") ; echo $numrows; ?>
  3. When i press login i get Fatal error: Call to a member function query() on a non-object in /home/a5347792/public_html/login.php on line 15 <?php $dbConnection['username'] = "root"; $dbConnection['password'] = ""; $dbConnection['host'] = "localhost"; $dbConnection['db'] = "joke"; if(isset($_POST['rbLgn'])) { $login = true; if(isset($_POST['username'])) { $username = $_POST['username']; } if(isset($_POST['password'])) { $password = $_POST['password']; } if(isset($username) && isset($password)) { $query = $db->query("SELECT * FROM `users` WHERE `username`='{$username}' AND `password`='{$password}' LIMIT 1"); if($query->num_rows > 0) { echo "User found - logging in."; } else { echo "User not found, credentials: " . $username . " | " . $password; } } } ?>
×
×
  • 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.