Jump to content


This topic is now archived and is closed to further replies.


Help with form processing, checkboxes and posting to MySQL

Recommended Posts

So I'm trying to work out an issue on a project which requires to post some data from a form and send it to multiple databases via several user selected checkboxes. I think I have this somewhat figured out but could use some help making sure it looks ok and I'm doing things the right way. Would appreciate some input if anyone has some ideas how to do this better or what have you... thanks very much!!

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";}?>>

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");

//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!!!



Share this post

Link to post
Share on other sites
I think it should work if you remove the quotes:

[code=php:0]$query = db_insert(compid,title,categoryid,subcategoryid,description,locationid,skills);[/code]

Share this post

Link to post
Share on other sites


Important Information

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.