# Hello login problem (PHP question)

**URL:** <https://forum.freecodecamp.org/t/hello-login-problem-php-question/169470>\
**Category:** General\
**Created:** [January 18, 2018, 11:36am UTC](https://forum.freecodecamp.org/t/hello-login-problem-php-question/169470 "2018-01-18T11:36:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![donjon](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/donjon/32/110909_2.png) [@donjon](https://forum.freecodecamp.org/u/donjon)\
**Post date:** [January 18, 2018, 11:36am UTC](https://forum.freecodecamp.org/t/hello-login-problem-php-question/169470/1 "2018-01-18T11:36:54Z")

</div>

```auto
* <?php
* session_start() ;
* $server = 'localhost';
* $user= 'root';
* $pass = '';
* $database = 'users';
* try{
* $conn = new PDO("mysql:host=$server;dbname=$database;", $user, $pass);
* } catch(PDOException $e){
* die("connection failed:" .$e->getmessage());
* }
* if(!empty($_POST['username']) && !empty($_POST['password'])):

* $records = $conn->prepare("SELECT * FROM table2 WHERE username = :username AND password = ':password'");

* $records->bindParam(':username', $_POST['username']);
* $records->bindparam(':password', $_POST['password']);
* $records->execute(
* array(
* 'username' => $_POST["username"],
* 'password' => $_POST["password"]
* )
* );
* $count = $records=>rowcount();
* if($count > 0)
* { echo "sucess";
* 		
* }
* //$results = $records->fetch(PDO::FETCH_ASSOC);
* ///if(count($results) > 0 && password_verify($_POST['password'],$results['password'])) {
* die('we have a login');

* 	
* }
* //else {
* 		
* ///header("location:index3.php");
* 	

* //endif;

* ?>
* <html>

* <link rel="stylesheet" type="text/css" href="style.css">
* <link href="https://fonts.googleapis.com/css?family=Supermercado+One" rel="stylesheet">

* <form action="login.php" method="post" > 

* username <input type="text" placeholder="enter your username" name= "username" />
* password <input type="password" name= "password" />
* <input type="submit" />
* <form/>
* </html>

```

Hello im trying to create my own login page my signup page works great but login doesnt work  
only get we failed message or fault message

---

<div class="post-metadata">

**Author:** ![Soupedenuit](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/soupedenuit/32/32478_2.png) [@Soupedenuit](https://forum.freecodecamp.org/u/Soupedenuit)\
**Post date:** [January 19, 2018, 4:56am UTC](https://forum.freecodecamp.org/t/hello-login-problem-php-question/169470/2 "2018-01-19T04:56:17Z")

</div>

I have modified your title and added ‘(PHP question)’ as your question is not related to FCC or our curriculum and gave the impression you were having trouble logging in to FCC. Someone will hopefully help you out. There are many members here who are knowledgeable in PHP (I am not).

---

<div class="post-metadata">

**Author:** ![sofaires](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sofaires/32/160791_2.png) [@sofaires](https://forum.freecodecamp.org/u/sofaires)\
**Post date:** [January 19, 2018, 6:03am UTC](https://forum.freecodecamp.org/t/hello-login-problem-php-question/169470/3 "2018-01-19T06:03:15Z")

</div>

what error you are getting?

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:30pm UTC](https://forum.freecodecamp.org/t/hello-login-problem-php-question/169470/4 "2021-01-17T20:30:00Z")

</div>

Closed on January 17, 2021, 8:30pm UTC


