close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Insert from login page

Thread began 10/07/2009 2:38 pm by rogersds267040 | Last modified 10/19/2009 2:25 pm by Jason Byrnes | 1602 views | 9 replies |

rogersds267040

Insert from login page

I'm trying to insert the userID stored in a session into a database and it just will not insert. What am I doing wrong?

Below is the login page code:



<?php require_once('Connections/first.php');?>
<?php require_once("WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once("WA_SecurityAssist/WA_SHA1Encryption.php"); ?>
<?php require_once( "WA_SecurityAssist/Helper_PHP.php" ); ?>
<?php
if ((((isset($_POST["remembermeoption"]))?$_POST["remembermeoption"]:"") != "")) {
setcookie("RememberMePWD", "".((isset($_POST["userpassword"]))?$_POST["userpassword"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}
?>
<?php
if ((((isset($_POST["remembermeoption"]))?$_POST["remembermeoption"]:"") != "")) {
setcookie("RememberMeUN", "".((isset($_POST["username"]))?$_POST["username"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}
?>
<?php
if (isset($_POST["LogIn_x"]) && !isset($_POST["remembermeoption"])) {
setcookie("RememberMePWD", "", time()+(60*60*24*30), "/", "", 0);
}
?>
<?php
if (isset($_POST["LogIn_x"]) && !isset($_POST["remembermeoption"])) {
setcookie("RememberMeUN", "", time()+(60*60*24*30), "/", "", 0);
}
?>
<?php
if(isset($_POST["LogIn_x"])){
$WA_Auth_Parameter = array(
"connection" => $first,
"database" => $database_first,
"tableName" => "users",
"columns" => explode($WA_Auth_Separator,"userCSRID".$WA_Auth_Separator."userpassword"),
"columnValues" => explode($WA_Auth_Separator,"".((isset($_POST["username"]))?$_POST["username"]:"") ."".$WA_Auth_Separator."".WA_SHA1Encryption(((isset($_POST["userpassword"]))?$_POST["userpassword"]:"")) .""),
"columnTypes" => explode($WA_Auth_Separator,"text".$WA_Auth_Separator."text"),
"sessionColumns" => explode($WA_Auth_Separator,"userID".$WA_Auth_Separator."userLevel".$WA_Auth_Separator."userCSRID".$WA_Auth_Separator."userActive".$WA_Auth_Separator."firstLogIn"),
"sessionNames" => explode($WA_Auth_Separator,"userID".$WA_Auth_Separator."userLevel".$WA_Auth_Separator."userCSRID".$WA_Auth_Separator."userActive".$WA_Auth_Separator."firstLogIn"),
"successRedirect" => "users_Profile.php",
"failRedirect" => "users_LogIn.php?failed=1",
"gotoPreviousURL" => TRUE,
"keepQueryString" => TRUE
);

WA_AuthenticateUser($WA_Auth_Parameter);
}?>
<?php
// WA Application Builder Insert
if ($_SERVER["REQUEST_METHOD"] == "POST") // Trigger
{
$WA_connection = $first;
$WA_table = "user_LogTime";
$WA_sessionName = "user_LogTime_logID";
$WA_redirectURL = "";
$WA_keepQueryString = false;
$WA_indexField = "logID";
$WA_fieldNamesStr = "logUserID";
$WA_fieldValuesStr = "".$_SESSION['userCSRID'] ."";
$WA_columnTypesStr = "none,none,NULL";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_first;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<?php

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 != "") ? "'" . date("Y-m-d",strtotime($theValue)) . "'" : "NULL";
break;
case "time":
$theValue = ($theValue != "") ? "'" . date("H:i:s",strtotime($theValue)) . "'" : "NULL";
break;
case "datetime":
$theValue = ($theValue != "") ? "'" . date("Y-m-d H:i:s",strtotime($theValue)) . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
?>

Sign in to reply to this post

Eric Mittman

It looks like you are storing the userCSRID value in a session variable and then trying to insert that session variable into your user_LogTime table. Do you get any record to insert into the table? Have you checked this session variable to ensure that it is has a value?

You can do a check just after the trigger for the insert by adding in this code:

php:
// WA Application Builder Insert

if ($_SERVER["REQUEST_METHOD"] == "POST") // Trigger
{
die("the userCSRID is: " . $_SESSION['userCSRID']);



So long as this session variable has a value it should be inserted into the table. Also, I noticed the trigger for your login was login button pressed but the trigger for your insert is any page post. You should update the trigger for the insert to be like the trigger for your login.

Sign in to reply to this post

rogersds267040

Insert from login page

It still doesn't insert into the table.


<?php require_once('Connections/first.php');?>
<?php require_once("WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once("WA_SecurityAssist/WA_SHA1Encryption.php"); ?>
<?php require_once( "WA_SecurityAssist/Helper_PHP.php" ); ?>
<?php
if ((((isset($_POST["remembermeoption"]))?$_POST["remembermeoption"]:"") != "")) {
setcookie("RememberMePWD", "".((isset($_POST["userpassword"]))?$_POST["userpassword"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}
?>
<?php
if ((((isset($_POST["remembermeoption"]))?$_POST["remembermeoption"]:"") != "")) {
setcookie("RememberMeUN", "".((isset($_POST["username"]))?$_POST["username"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}
?>
<?php
if (isset($_POST["LogIn_x"]) && !isset($_POST["remembermeoption"])) {
setcookie("RememberMePWD", "", time()+(60*60*24*30), "/", "", 0);
}
?>
<?php
if (isset($_POST["LogIn_x"]) && !isset($_POST["remembermeoption"])) {
setcookie("RememberMeUN", "", time()+(60*60*24*30), "/", "", 0);
}
?>
<?php

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 != "") ? "'" . date("Y-m-d",strtotime($theValue)) . "'" : "NULL";
break;
case "time":
$theValue = ($theValue != "") ? "'" . date("H:i:s",strtotime($theValue)) . "'" : "NULL";
break;
case "datetime":
$theValue = ($theValue != "") ? "'" . date("Y-m-d H:i:s",strtotime($theValue)) . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
?>
<?php
if(isset($_POST["LogIn_x"])){
$WA_Auth_Parameter = array(
"connection" => $first,
"database" => $database_first,
"tableName" => "users",
"columns" => explode($WA_Auth_Separator,"userCSRID".$WA_Auth_Separator."userpassword"),
"columnValues" => explode($WA_Auth_Separator,"".((isset($_POST["username"]))?$_POST["username"]:"") ."".$WA_Auth_Separator."".WA_SHA1Encryption(((isset($_POST["userpassword"]))?$_POST["userpassword"]:"")) .""),
"columnTypes" => explode($WA_Auth_Separator,"text".$WA_Auth_Separator."text"),
"sessionColumns" => explode($WA_Auth_Separator,"userID".$WA_Auth_Separator."userLevel".$WA_Auth_Separator."userCSRID".$WA_Auth_Separator."userActive".$WA_Auth_Separator."firstLogIn"),
"sessionNames" => explode($WA_Auth_Separator,"userID".$WA_Auth_Separator."userLevel".$WA_Auth_Separator."userCSRID".$WA_Auth_Separator."userActive".$WA_Auth_Separator."firstLogIn"),
"successRedirect" => "users_Profile.php",
"failRedirect" => "users_LogIn.php?failed=1",
"gotoPreviousURL" => TRUE,
"keepQueryString" => TRUE
);

WA_AuthenticateUser($WA_Auth_Parameter);
}?>
<?php
// WA Application Builder Insert
if (isset($_POST["LogIn_x"])) // Trigger
{
$WA_connection = $first;
$WA_table = "user_LogTime";
$WA_sessionName = "user_LogTime_logID";
$WA_redirectURL = "";
$WA_keepQueryString = false;
$WA_indexField = "logID";
$WA_fieldNamesStr = "logUserID";
$WA_fieldValuesStr = "".((isset($_POST["logUserID"]))?$_POST["logUserID"]:"") ."";
$WA_columnTypesStr = "',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_first;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>


<div id="LogInContainer" class="WAATK">
<form method="POST" name="WAATKLogInForm" id="WAATKLogInForm">
<h1>Please Log In</h1>
<table class="WAATKDataTable" cellpadding="0" cellspacing="0" border="0">
<?php if(WA_Auth_RulePasses("Login Failed")){ // Begin Show Region ?>
<tr>
<th>&nbsp;</th>
<td><span class="textfieldServerError" >The login information provided is not valid. Please try again.</span></td>
</tr>
<?php } // End Show Region ?>
<tr>
<th>Enter your CSRID</th>
<td><span id="sprytextfield1">
<input type="text" class="WAATKTextField" name="username" value="<?php echo((isset($_COOKIE["RememberMeUN"]) && isset($_COOKIE["RememberMePWD"]))?$_COOKIE["RememberMeUN"]:"") ?>" />
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<th>Password</th>
<td><span id="sprypassword1">
<input type="password" class="WAATKTextField" name="userpassword" value="<?php echo((isset($_COOKIE["RememberMePWD"]))?$_COOKIE["RememberMePWD"]:"") ?>" />
<span class="passwordRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<th class="WAATKDataTableHeader"><input type="checkbox" name="remembermeoption" <?php echo((isset($_COOKIE["RememberMeUN"]))?"checked":"") ?> value="1" /></th>
<td class="WAATKDataTableCell">Remember me</td>
</tr>
<tr>
<th class="WAATKDataTableHeader">&nbsp;</th>
<td class="WAATKDataTableCell"><span class="WAATKDataTableHeader">(<a href="users_EmailPW.php">forgot</a> your password?)</span></td>
</tr>
</table>
<div class="WAATKButtonRow">
<input type="image" hspace="0" vspace="0" border="0" name="LogIn" id="LogIn" value="Log In" alt="Log In" src="WA_DataAssist/images/Slate/Refined_insert.gif" />
<input name="logUserID" type="hidden" id="logUserID" value="<?php echo $_SESSION['userCSRID']; ?>" />
</div>
</form>
</div>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur"]});
var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1", {validateOn:["blur"]});
//-->
</script>

Sign in to reply to this post

Eric Mittman

Did you put in the die statement? I did not see it, please add this in and test the insert, instead of inserting it should go to a blank white screen with a message about the session variable.

In the future in you would like to post your pages please attach them to your post in a zip archive or a text file.

Sign in to reply to this post

rogersds267040

Insert from login page

I have attached the login.php and profile.php page.

Sign in to reply to this post

Eric Mittman

It looks like your pages did not get attached to your post. You must have them in a zip file to attach them. Did you get any output from the die statement? I think it is just a problem with the session values that should be set. This test should tell us more about what the problem is.

Sign in to reply to this post

rogersds267040

Insert from login page

Find the attached pages. When I add the code Im directed to a blank page.

Attached Files
Pages.zip
Sign in to reply to this post

Jason ByrnesWebAssist

The Authenticate user server behavior is redirecting to the users_Profile.php page before the insert Record behavior can run.

Double click the Authenticate user server behavior and remove the redirect to the users_Profile.php page, then double click the Insert Record server behavior and set it to redirect to the users_Profile.php page after the insert takes place.

Sign in to reply to this post

rogersds267040

Insert from login page

Thanks it work

Sign in to reply to this post

Jason ByrnesWebAssist

You're welcome.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...