PHP MySQL not submitting or working -


i have php , html code should send data form mysql database. however, on clicking submit in form, page reloads , nothing happens. no echo or anything. html in same file php file.

php

<?php  if(isset($_post['submit'])){     $usernamep = $_post['usernameinput'];     $passwordp = $_post['passwordinput'];      $servername = "localhost";     $username = "usernamecensor";     $password = "passwordcensor";     $dbname = "database";      try {         $conn = new pdo("mysql:host=$servername;dbname=$dbname", $username, $password);         // set pdo error mode exception         $conn->setattribute(pdo::attr_errmode, pdo::errmode_exception);         $sql = "insert accounts (username, password)         values ('$usernamep', '$passwordp')";         // use exec() because no results returned         $conn->exec($sql);         echo "success";     }     catch(pdoexception $e)     {         echo $sql . "<br>" . $e->getmessage();     }     $conn = null; } ?> 

html

<form method="post" action="">     <input type="text" name="usernameinput"><br>     <input type="password" name="passwordinput"><br>     <input type="submit" class="button" value="sign in"> </form> 

note: know code subject sql injection, , password not encrypted. temporary starting code in attempt working first.

you lack name attribute in submit button, add name="submit".

<form method="post" action="">     <input type="text" name="usernameinput"><br>     <input type="password" name="passwordinput"><br>     <input type="submit" name="submit" class="button" value="sign in"> </form> 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -