Copy link to clipboard
Copied
Hi all,
I'm new here at the dreamweaver forum and also a new dreamweaver user, and hope you can help me out with this issue.
I'm trying to create a part on my website where the logged in user fills in a form and after clicking a "create contract" button it genarates an online contract where the fileds get data from mysql table.
I have already succeded in creating a connection with mysql and created an insert record behavior and created the following webpage (the template for the contract with the same fields in the form), but I dont know how to proceed from here. How do I make to get the last generated data from this speficic user (since I will have some users logged in at the same time)?
Hope you can help me out here...
Tks in advance.
Anna
Copy link to clipboard
Copied
Hi,
After some online research I've created a recordset and created a session variable filtering by id, after that I draged each mysql field into the php cell from the recordset panel.
But it is not working...
$colname_retrieve_data = "-1";
if (isset($_SESSION['LAST_INSERT_ID()'])) {
$colname_retrieve_data = $_SESSION['LAST_INSERT_ID()'];
}
mysql_select_db($database_locaweb, $locaweb);
$query_retrieve_data = sprintf("SELECT * FROM dados_contrato WHERE id = %s", GetSQLValueString($colname_retrieve_data, "int"));
$retrieve_data = mysql_query($query_retrieve_data, $locaweb) or die(mysql_error());
$row_retrieve_data = mysql_fetch_assoc($retrieve_data);
$totalRows_retrieve_data = mysql_num_rows($retrieve_data);
What I'm I doing wrong? Just remembering I nee to retrieve the last data inserted by the loged in user.
Anyone can help ?
Copy link to clipboard
Copied
Hey,
I'm still trying to make this works... some more research and I got this:
1) created a php form (my page 1) to post the data, in this form I created only an insert record server behavior
2) created a contract page (second page), where I set up a session variable as follow
<?php session_start(); session_register("sess_id"); $sess_id = $HTTP_POST_VARS['id']; ?>
where "id" is the autoincrement field filled in with my page 1 post.
Then I inserted a session variable, and named it "sess_id", the same as I named in the session_start, and draged it into my code.
<?php echo $_SESSION['sess_id']; ?>
Then I created a recordset, and in the filter I choose "id" = session variable "id" (also tried as session variable "sess_id", since I dont know if I was supposed to just leave the field or the session name), and in the bindings window I draged the fields into the respective cells.
But is still not working ! now I'm getting this messages...
( ! ) Deprecated: Function session_register() is deprecated in C:\wamp\www\contratos\contrato_ts_session.php on line 2 Call Stack # Time Memory Function Location 1 0.0013 733024 {main}( ) ..\contrato_ts_session.php:0 ( ! ) Notice: Undefined variable: HTTP_POST_VARS in C:\wamp\www\contratos\contrato_ts_session.php on line 2 Call Stack # Time Memory Function Location 1 0.0013 733024 {main}( ) ..\contrato_ts_session.php:0
Can anyone please help with this ? What am I doing wrong?
Follow the whole php code
<?php require_once('Connections/locaweb.php'); ?>
<?php session_start(); session_register("sess_id"); $sess_id = $HTTP_POST_VARS['id']; ?>
<?php echo $_SESSION['sess_id']; ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_Recordset1 = "-1";
if (isset($_SESSION['sess_id'])) {
$colname_Recordset1 = $_SESSION['sess_id'];
}
mysql_select_db($database_locaweb, $locaweb);
$query_Recordset1 = sprintf("SELECT * FROM dados_contrato WHERE id = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $locaweb) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>