Paul_W
-
Posts
1 -
Joined
-
Last visited
Never
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Help with form processing, checkboxes and posting to MySQL
in PHP Coding Help
Posted
So the form itself is fairly straight forward:
<FORM action="process.php" method="post" name="frmJob">
...
bunch of text areas and other checkboxes
...
<input type="checkbox" class="radio" name="post_1" id="id_a" value="1"<?php if($t_result['post_1'] == "1") { echo " checked";}?>>
</FORM>
so in process.php I have this:
$query = '<Database INSERT/UPDATE query here>';
if(isset($_POST['post_1'])) {
// connect to db 1
$db_link = mysql_connect ( $db_hostname, $db_server_username, $db_server_password );
if ( $db_link ) {
if ( ! mysql_select_db ( $db_database ) ){
die("Mysql connection failed");
}
else{
mysql_query($query);
//close the database connection
@mysql_close ( $db_link );
//connect back to normal database server
xx_db_connect() or die('Unable to connect to database server!');
}
} else {
die("Mysql connection failed");
repeat for more checkboxes....
One thing I'm curious about is can I use a function in the $query = ''; so something like this
$query = 'db_insert(compid,title,categoryid,subcategoryid,description,locationid,skills)';
Any further examples or comments or suggestions are welcome!!!
Thanks,
Paul