Jump to content


Help with form processing, checkboxes and posting to MySQL

  • Please log in to reply
1 reply to this topic

#1 Paul_W

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 17 August 2006 - 06:19 AM

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



#2 Jeremysr

  • Members
  • PipPipPip
  • Advanced Member
  • 199 posts
  • LocationSaskatchewan, Canada

Posted 17 August 2006 - 06:24 AM

I think it should work if you remove the quotes:

$query = db_insert(compid,title,categoryid,subcategoryid,description,locationid,skills);

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users