0

I want to get data from phpmyadmin which i have installed on EC2 through a php page i made and but no response is coming the error is : The X.X.X.X page isn’t working X.X.X.X is currently unable to handle this request. HTTP ERROR 500 on loginbd.php

login.html

<html>
<body>
<form method="post" action="http://X.X.X.X/test/logindb.php">
UserName:<input type="text" name="usr"><br><br>
Password:<input type="password" name="pwd"><br><br>
<center><input type="submit" name="sub" value="Login"/></center><br><br>
</form>
</body>
</html>

logindb.php

<?php
$host="localhost";
$username="XXXX";
$password="Something i can't tell";
$db_name="sv_db";
$tbl_name="users";
$conn = mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['usr'];
$mypassword=$_POST['pwd'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="select * from $tbl_name where password='$mypassword' AND       username='$myusername'";
$result=mysql_query($sql,$conn);
$count=mysql_num_rows($result);
if ($count == 1)
{
echo ":) :) LOGIN SUCCESS :) :) ";
}
else 
{
echo ":( :( AUTHETICATION FAILURE :( :( ";
}
?>
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 1
    `phpMyAdmin` is a tool written in PHP to help maintain and manipulate a **MySQL** database. – RiggsFolly Mar 12 '17 at 13:24
  • 2
    Your script is at risk of [SQL Injection Attack](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) Have a look at what happened to [Little Bobby Tables](http://bobby-tables.com/) Even [if you are escaping inputs, its not safe!](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) Use [prepared parameterized statements](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) – RiggsFolly Mar 12 '17 at 13:24
  • What version of PHP did you install into your server? – RiggsFolly Mar 12 '17 at 13:28
  • So sorry got used to mysql_ :( :( and thank you for helping me out. PHP7 it is. – sandeep rawat Mar 12 '17 at 14:03

1 Answers1

0

The mysql_ database extension has been withdrawn in PHP7.

You will have to use the mysqli_ or PDO database extensions now.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149