PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
var_dump($_POST)
if (!empty($_POST))
{
if (isset($_POST['username']) && isset($_POST['password']))
{
$connect = mysql_connect("localhost","root","") or die("Could not connect");
mysql_select_db("tracker") or die("Could not find database");
}
else
die("Incorrect information");
}
?>
That one should work fine. You won't see any output to screen because you haven't done anything that produces any. You can echo some dummy text after selecting your database to confirm it's working if you like.
<?php
if (!empty($_POST))
{
if (isset($_POST['username']) && isset($_POST['password']))
{
$connect = mysql_connect("localhost","root","") or die("Could not connect");
mysql_select_db("tracker") or die("Could not find database");
echo'testing';
}
else
die("Incorrect information");
}
?>
I implemented mysqli a few minutes ago and I've not received any errors, so I'm assuming I've done it correctly. With that being said, the issue I'm having still exists.
if (isset($_POST['username']) && isset($_POST['password']))
{
$mysqli = new mysqli();
$mysqli = new mysqli('localhost', 'root', '', 'tracker');
}
else
die('Unable to proceed');
If I am correct, then this line of code basically says "If you don't provide me with a correct username or password, I'm closing the connection and telling you "Unable to proceed".
It's not performing any authentication. That block, in English, would ready "If a (any) username and password have been provided, open a connection to the database. Otherwise, don't and inform the user you couldn't." Or something to that effect.