As I am using PHP to connect to mysql database. I tried to connect to database and similarly I want to insert data into Database whenever I click to login button on my form. But no changes are shown db when I try this code so please any help with it. Thank you..
<?php
$servername = "localhost";
$username = "root";
$password = "password";
$conn = new PDO("mysql:host=$servername;dbname=Akalpa", $username, $password); // connection to my sql database
if(isset($_POST['Log In'])){
$username=$_POST['username'];
$query = "Insert into User(username) values('$username')"; //query to insert to db
if (mysql_query($query)) //checking the query
{
echo"<h3>Inserted Successfully</h3>"; //value inserted to db successfully
}
}
?>
mysql_query($query)with$conn->query( $query )and look at Jack M's answer, because you should be doing more to be safe.