Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6211131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:17:02+00:00 2026-05-24T06:17:02+00:00

I have following html: <label for=live>Live</label> <input type=checkbox name=live id=live /> How to save

  • 0

I have following html:

<label for="live">Live</label>
<input type="checkbox" name="live" id="live" />

How to save text value of selected = '1'/ or text value of unchecked = '0' to database using SQL INSERT?

Any suggestion much appreciated.

PHP handling the html form (at the moment ‘live’ is an input):

<?php
    //Start session
    session_start();

    //Include database connection details
    require_once('../inc/config.php');

    //Connect to mysql server
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
    if(!$link) {
        die('Failed to connect to server: ' . mysql_error());
    }
    if($link) {
        echo "DB SUCESS <br />";
    }

    //Select database
    $db = mysql_select_db(DB_DATABASE);
    if(!$db) {
        die("Unable to select database");
    }
    if($db){ echo "TABLE SUCCESS<br />"; }

    //Function to sanitize values received from the form. Prevents SQL injection
    function clean($str) {
        $str = @trim($str);
        if(get_magic_quotes_gpc()) {
            $str = stripslashes($str);
        }
        return mysql_real_escape_string($str);
    }

    //Sanitize the POST values
    $live = clean($_POST['live']);
    $content = clean($_POST['content']);


        //Create INSERT query
    $qry = "INSERT INTO news(live, content) VALUES('$live','$content') ";
    $result = @mysql_query($qry);

    //Check whether the query was successful or not
    if($result) {
        //header("location: ../form/register-success.php");
        echo "Succes";      
        exit();
    }else {
        die("Query failed");
    }
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:17:02+00:00Added an answer on May 24, 2026 at 6:17 am
    <input type="checkbox" name="live" value="1" />Live<br />
    

    ^Note the Value “1”. If someone checks the box, it will be a 1, if they don’t it will be NULL. (NOT 0!)

    Do an isset on the next page, if it’s set, you’re good to go, if it’s not, just set it to zero.

    if (!isset($live)) $live = 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML <div> <label for=username>Username:</label> <input type=text name=username id=username /> <span>some
I have the following HTML : <label> <input type='checkbox' checked=checked /> CLICK ME.... </label>
I have a the following html: <label>blah</label> <input type=text ... /> I want the
I have the following html: <label class=description>Label Text</label><input type=password /> And the css styles
I have the following HTML: <label class=fileinput-button> <span>add file...</span> <input type=file name=file disabled> </label>
I have the following html: <style type=text/css> .message-view-value-td { vertical-align:bottom; } </style> <table width=600>
So I have the following html: <div id=divForComponents> <input type=button value=+ onclick=addFilter('divForComponents')/> </div> And
I have the following <label for=Forename>Forename</label> <%= Html.TextBoxFor(m => m.Customer.Name.Forename) %> the problem with
I have the following HTML <select> element: <select id=leaveCode name=leaveCode> <option value=10>Annual Leave</option> <option
I have the following html: <div class=bf_form_row> <label for=findout>Text goes here</label> <textarea class=findOut cols=40

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.