styfle / The-Harvest-Club

🍊A student-designed Contact Management System for connecting volunteers and growers
https://styfle.github.io/The-Harvest-Club/
6 stars 3 forks source link

Update submit forms - use $db object #7

Closed styfle closed 12 years ago

styfle commented 12 years ago

The Database class has a nice feature to escape your query for you. I haven't tested so tell me if it breaks.

include('include/Database.inc.php');
// say you get $tablename and $first_name from $_POST array
// make sure they are set first. if not die and tell the user why
$sql = "SELECT * FROM %s WHERE first_name = '%s';";
$r = $db->q($sql, array($tablename, $first_name));
// now do whatever you need to with result

That should get you started. See ajax.php for more.

Secondly, I think these can actually be included in the top of the form files by using require_once('include/submit-grower.php') and such. This will perform the checks and print the message on the current page. First fix the $db issue, then we can look at including it.

SgtRaccoon commented 12 years ago

I'll get started on this ASAP.

styfle commented 12 years ago

Closed. See #4.