Health & Medical sports & Exercise

How to Add Hidden Fields in MySQL

    • 1). Right-click the PHP file you want to edit. Click "Open With," then click the PHP editor you want to use to process the hidden field element.

    • 2). Type the following code to retrieve the element:

      $hidden = $_POST['fieldname'];

      Replace "fieldname" with the name of the hidden field in the HTML form. The code above gets the value in the hidden field.

    • 3). Create the connection to the MySQL database. Use the following code to connect to the database and replace the database name, server name, username and password values with your own:

      $connect = mysql_connect("server_name","username","password");

      mysql_select_db("database_name", $connect);

    • 4). Create the MySQL insert statement that uses the hidden field's value. The following code inserts the hidden field into the tables "customfield" field:

      $query = "insert into customer (customfield) values ('".$hidden.";)";

    • 5). Insert the value into the database. Using the query built in step four and the previous database connection, you can insert the hidden field value:

      mysql_query($query);

Leave a reply