Skip to main content
October 8, 2010
Question

While viewing a detail page, a hidden form submits into a seperate table without having to click...

  • October 8, 2010
  • 2 replies
  • 2340 views

Hello, everyone:

I am having hard time explaining what I want.

Is there a way to insert data into a table without clicking on the submit button.

Let me explain.  I have a table that I want to populate.  In DW4 I have created a list of records.  I click on a link which opens a seperate page showing the details of my choosing.  What I want to do is have a seperate hidden table in my detail page that inserts my record I selected.  In my hidden table which is created by DW4 insert record to add certain information about the user and his/her choice of record.  The problem I am facing is DW4 creates a submit button.

My question is, in my list of records, when I click on a link from the list of records to view my details, how can I insert hidden information to another table without clicking on the submit button (which I do not want anyone to see) while in the detail page without it refreshing the page.  Is this possible.

I hope I have not made this confusing for anyone.

Thank you,

AdonaiEchad

This topic has been closed for replies.

2 replies

November 4, 2010

I am going to refine my thinking here, it maybe a little bit of a repeat.

In my list.php page where I have links that goes to my details.php.

In my details.php page can it execute without refreshing, without hitting a submit button through a form or using AJAX?

Once I click on my list.php link that leads me to my details.php page as soon as that details.php page opens up in my browser, can there be a hidden form or some PHP code that can insert into a different table?  Some information from that different table that is being populated is from the details.php page and some is other stuff like I.P. address and timestamps.

I hope this simplifies what I am looking for.

Participating Frequently
November 4, 2010

>Once I click on my list.php link that leads

>me to my details.php page as  soon as that

>details.php page opens up in my browser,

>can there be a  hidden form or some PHP

>code that can insert into a different table?

You don't need a hidden form. Forms are a user interface device - used to gather data input from users. You simply need to to execute a script when the page opens. The script can process data passed to it from forms on other pages, from session variables, from server variables, or from query strings. You can then use that data in you insert statement. Or you can use it to extract more data from your database that can then be used in your insert statement. You don't need AJAX to accomplish any of this.

December 1, 2010

AdonaiEchad wrote:

In your statement,

You simply need to to execute a script when the page opens. The script can process data passed to it from forms on other pages, from session variables, from server variables, or from query strings. You can then use that data in you insert statement. Or you can use it to extract more data from your database that can then be used in your insert statement.

how do I make a query that inserts as you stated.

Sounds rediculous but I do not know how to hand code this.  I am so used to having DW4 code the insert but it creates a form for me.

I provided an example in the last reply. Here's a hand-hold:

<?php

// If URL parameter is set and user is logged in then connect to database and insert query.

if ((isset($_GET['id'])) && (isset($_SESSION['username']))) {

$servername='localhost';
$dbuser='xxxxxx';
$dbpassword='xxxxxx';
$dbname='xxxxxx';

// Connect to server and select database.
mysql_connect("$servername", "$dbuser", "$dbpassword")or die("cannot connect");
mysql_select_db("$dbname")or die("cannot select DB");

// Insert data into database

mysql_query("INSERT INTO table_name

(product_id, client, ip_address, date)
VALUES

($_GET['id'], $_SESSION['username'], $_SERVER['REMOTE_ADDR'], date("Y-m-d"))");

} ?>


Everything is working properly.

I want to take it to the next level, how do I update just like I have inserted.

Insert

--------

// Insert data into database

mysql_query("INSERT INTO table_name

(product_id, client, ip_address, date)
VALUES

($_GET['id'], $_SESSION['username'], $_SERVER['REMOTE_ADDR'], date("Y-m-d"))");

} ?>

Update

---------

$colname_getUser = "-1";
if (isset($_GET['userid'])) {
  $colname_getUser = $_GET['userid'];
}
mysql_select_db($database_conOnDemand, $conOnDemand);
$query_getUser = sprintf("SELECT * FROM useracct WHERE userid = %s", GetSQLValueString($colname_getUser, "text"));
$getUser = mysql_query($query_getUser, $conOnDemand) or die(mysql_error());
$row_getUser = mysql_fetch_assoc($getUser);
$totalRows_getUser = mysql_num_rows($getUser);

// update data into database

mysql_query("UPDATE useracct SET lastlogindate=%s, WHERE userid=%s",
                       GetSQLValueString(date('Y-m-d H:i:s'), "date"),
                       GetSQLValueString($row_getUser['userid'], "text"));

I cannot get the update to fill in the field "lastlogindate"

Participating Frequently
October 8, 2010

Use AJAX

October 8, 2010

I know this sounds stupid.  But how do I do that.  I am not familuar with AJAX.  Does DW4 have it in their Spry insert select?

October 8, 2010

My question is, in my list of records, when I click on a link from the list of records to view my details, how can I insert hidden information to another table without clicking on the submit button

Ajax is not necessary. You click a link to visit the detail page. Make the link submit the form with hidden fields. Problem solved!