Jump to content

Hendz

New Members
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Hendz

  • Rank
    Newbie
  1. Hi Guys ive given this a go and im continuing to learn php. I want to check from a login section to see does the username exist in the database. Ive gotten this far but i feel like im miles away. Any suggestions would be appreciated. <?php require "config.php"; try { $pdo = new PDO("mysql:host=$host", $username, $password, $options); echo 'DB connected'; } catch (PDOException $e) { throw new PDOException($e->getMessage(), (int)$e->getCode()); } $stmt = $pdo->query('SELECT username FROM databasetest.login WHERE username = !null'); while
  2. @requinix I created a new pdo Object, and fed in details of db like in config file. It doesnt throw the error anymore but then again when i run it it doesnt add given data lol. Sorry, Im php noob. im normally a java dev just learning this is stressful. class UserQuery { public function Adduser($id,$username,$email,$password){ $dsn = "mysql:dbname=test;host=127.0.0.1:3306"; $user = "root"; $passwd = "2194"; $pdo = new PDO($dsn, $user, $passwd); $sql =("INSERT INTO test.user (id, username, email, password) VALUES ('$id', '$username', '$email',$passw
  3. Yeah, i understand it needs to exist but ive read so much and cant figure it out. any hints to guide me in the right direction to solve this problem ?
  4. <?php class UserQuery { public function Adduser($id,$username,$email,$password) { $conn = new Config(); $sql =("INSERT INTO test.user (id, username, email, password) VALUES ('$id', '$username', '$email',$password)"); $conn->exec($sql); } } getting an "exec doesnt exist " error, saying exec doesnt exist in my db file. it doesnt need to exist does it ? anyone any idea why ?
  5. Thanks i added the name + id and it fixed my proble. enjoying php pretty similar to Java but just getting the hang of OOP and PDO a learning experience lol
  6. i Have this Form <form action="action_page.php" method="POST"> <div class="form-group"> <label for="email">Email address:</label> <input type="email" class="form-control" id="email"> </div> <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd"> </div> <div class="checkbox"> <label><input type="checkbox"> Remember me</label> </div> <button type="submit" class="btn btn-default">Submit</button> </form>
×
×
  • 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.