I know how to make a set query display, but I need to take an input, run a statement, and display the result. Here is what I have:
HTML:
<form name="form3" method="post" action="sqlexp.php">
<input name="sqlstatement" type="text" id="sqlstatement" style="width: 340px;">
<input type="submit" name="create" value="Create">
</form>
PHP:
ob_start();
$host = "localhost"; // Host name
$username = "root"; // Mysql username
$password = "Passw0rd"; // Mysql password
$db_name = "time_tracker"; // Database name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password") or die("cannot connect");
mysql_select_db("$db_name") or die("cannot select DB");
// Define $sqlstatement
$sqlstatement = $_POST['sqlstatement'];
// runs statement
$sql = " $sqlstatement ";
$result = mysql_query($sql);
echo $sql;
echo $result;
ob_end_flush();
I also want to make the statements read only so nobody can mess with my tables. im a little new to this i might need some extra explaining