Jump to content


New Members
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About pouria25

  • Rank
  1. pouria25

    PHP Login Form by using PDO connection

    Thanks again, I don't get even the message " Connected successfully"! Can you tell me what can I try like a query? I'm really a beginner with PHP, please? I've not thought it'll be so complicated to understand! Yours sincerely
  2. pouria25

    PHP Login Form by using PDO connection

    Hi I've written as you told me but now I don't know if my DSN.Connection is connected to my database or not? How can µI understand that? <?php $host = 'localhost'; $db = 'cool'; $user = 'myweb'; $pass = '*********'; $charset = 'utf8mb4'; $dsn = "mysql:host=$host;dbname=$db;charset=$charset"; $options = [ PDO::ATTR_ERRMODE =>PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE =>PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARS => false, ]; try { $pdo = new PDO($dsn, $user, $pass, $options); echo '<p style="color:#009933;">Connected successfully</p>'; } catch (\PDOEXCEPTION $e) { throw new \PDOException($e->getMessage(), (int)$e->getCode()); } ?> Yours faithfully
  3. pouria25

    PHP Login Form by using PDO connection

    Hi dearThank you for your answer I would like to ask you if even my connection works.Should I use a DNS connection?Yours faithfully
  4. Hi I'm a beginner and I would like to create a simple login form by using PDO connection. I wrote all these codes but nothing happened. The only thing I know is my PDO connection is working. Any help I appreciate that. login form: <!DOCTYPE html> <html> <form method="post" action="loginaccess.php"> <br> <br> Username <input type="text" name="username"> <br> <br> Password <input type="text" name="password"> <br> <br> <input value="submit" type="submit" name="submit"> <br> <br> <br> <br> </form> <?php require 'Connection.php'; session_start(); if(isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; $query = $conn->prepare("SELECT COUNT ('id') FROM 'users' WHERE 'username' = '$username' AND 'password' = '$password'"); $query-> execute(); $count = $query->fetchColumn(); if ($count > "0"){ $_SESSION['username'] = $username; header('location: panel.php'); } else { echo "Wrong informations"; } } ?> </html>

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.