close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Reflect changes to profile photo immediately after user updates their profile.

Thread began 4/26/2013 12:47 pm by Mysite07430650 | Last modified 4/29/2013 9:41 pm by Mysite07430650 | 1183 views | 12 replies |

Mysite07430650

Reflect changes to profile photo immediately after user updates their profile.

Hi Jason,

I need help with getting Digital File Pro to upload and immediately change profile photo within current session.

At present, I am able to update the profile photo, but in order to see the new photo just uploaded, I have to logout and log back in again. I am certain there is a way to update the profile photo and for the new photo to show up immediately after in the profile page.

Any advice and help is most welcome.

Many thanks in advance.

Sign in to reply to this post

Jason ByrnesWebAssist

are you storing the image name in a session on login?

if so, you will need to reset the session variable on the update page.

include a copy of the login and update page and i can give more details.

Sign in to reply to this post

Mysite07430650

Originally Said By: Jason Byrnes
  are you storing the image name in a session on login?

if so, you will need to reset the session variable on the update page.

include a copy of the login and update page and i can give more details.  


Thanks Jason,

Please find attached the login and userupdate page zip file.

Sign in to reply to this post

Jason ByrnesWebAssist

The problem is code order.

the image is using the SecurityAssistpcms2users recordsset:
<img src="../_images/userprofilethumb/<?php echo $row_SecurityAssistpcms2users['UserImage']; ?>" alt="Client Thumbnail Photo" name="cppmf100" width="50" height="50" id="cppmf100">Profile Photo

On the page, you have the recordset before the update behavior. move the code for the update behavior at lines 143 - 224:

php:
<?php 

// WA DataAssist Update
if ((isset($_POST["UserUpdate_submit"]) && $_POST["UserUpdate_submit"] != "")) // Trigger
{
  
$WA_connection $mfaccessConn;
  
$WA_table "pcms2_users";
  
$WA_redirectURL "userupdate.php?success=1";
  if (
function_exists("rel2abs")) $WA_redirectURL $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
  
$WA_keepQueryString true;
  
$WA_indexField "UserID";
  
$WA_fieldNamesStr "UserEmail|UserPassword|UserFirstName|UserLastName|UserCity|UserState|UserZip|UserPhone|UserFax|UserCountry|UserAddress|UserAddress2|UserImage|UserThumbnail|emailVerified";
  
$WA_fieldValuesStr "".((isset($_POST["User_Update_group_Email"]))?$_POST["User_Update_group_Email"]:"")  ."" $WA_AB_Split "".((($_POST["User_Update_group_Password"] != ""))?WA_SHA1Encryption($_POST["User_Update_group_Password"]):$row_SecurityAssistpcms2users["UserPassword"])  ."" $WA_AB_Split "".((isset($_POST["User_Update_group_First_Name"]))?$_POST["User_Update_group_First_Name"]:"")  ."" $WA_AB_Split "".((isset($_POST["User_Update_group_Last_Name"]))?$_POST["User_Update_group_Last_Name"]:"")  ."" $WA_AB_Split "".((isset($_POST["User_Update_group_City"]))?$_POST["User_Update_group_City"]:"")  ."" $WA_AB_Split "".((isset($_POST["User_Update_group_County"]))?$_POST["User_Update_group_County"]:"")  ."" $WA_AB_Split "".((isset($_POST["User_Update_group_10_Post_Code"]))?$_POST["User_Update_group_10_Post_Code"]:"")  ."" $WA_AB_Split "".((isset($_POST["User_Update_group_1_Telephone"]))?$_POST["User_Update_group_1_Telephone"]:"")  ."" $WA_AB_Split "".((isset($_POST["User_Update_group_1_Mobile"]))?$_POST["User_Update_group_1_Mobile"]:"")  ."" $WA_AB_Split "".((isset($_POST["User_Update_group_11_Country"]))?$_POST["User_Update_group_11_Country"]:"")  ."" $WA_AB_Split "".((isset($_POST["User_Update_group_Address_1"]))?$_POST["User_Update_group_Address_1"]:"")  ."" $WA_AB_Split "".((isset($_POST["User_Update_group_Address"]))?$_POST["User_Update_group_Address"]:"")  ."" $WA_AB_Split "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]  ."" $WA_AB_Split "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]  ."" $WA_AB_Split "".(($row_SecurityAssistpcms2users['UserEmail'] != $_POST["User_Update_group_Email"])? '0'$row_SecurityAssistpcms2users['emailVerified'])  ."";
  
$WA_columnTypesStr "',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|none,none,NULL";
  
$WA_comparisonStr "=|=|=|=|=|=|=|=|=|=|=|=|=|=|=";
  
$WA_fieldNames explode("|"$WA_fieldNamesStr);
  
$WA_fieldValues explode($WA_AB_Split$WA_fieldValuesStr);
  
$WA_columns explode("|"$WA_columnTypesStr);
  
  
$WA_where_fieldValuesStr "".((isset($_SESSION["SecurityAssist_UserID"]))?$_SESSION["SecurityAssist_UserID"]:"")  ."";
  
$WA_where_columnTypesStr "none,none,NULL";
  
$WA_where_comparisonStr "=";
  
$WA_where_fieldNames explode("|"$WA_indexField);
  
$WA_where_fieldValues explode($WA_AB_Split$WA_where_fieldValuesStr);
  
$WA_where_columns explode("|"$WA_where_columnTypesStr);
  
$WA_where_comparisons explode("|"$WA_where_comparisonStr);
  
  
$WA_connectionDB $database_mfaccessConn;
  
mysql_select_db($WA_connectionDB$WA_connection);
  @
session_start();
  
$updateParamsObj WA_AB_generateInsertParams($WA_fieldNames$WA_columns$WA_fieldValues, -1);
  
$WhereObj WA_AB_generateWhereClause($WA_where_fieldNames$WA_where_columns$WA_where_fieldValues,  $WA_where_comparisons );
  
$WA_Sql "UPDATE `" $WA_table "` SET " $updateParamsObj->WA_setValues " WHERE " $WhereObj->sqlWhereClause "";
  
$MM_editCmd mysql_query($WA_Sql$WA_connection) or die(mysql_error());
  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 
// WA DataAssist Update
if ((isset($_GET['send']) && $_GET['send'] != "")) // Trigger
{
  
$WA_connection $mfaccessConn;
  
$WA_table "pcms2_users";
  
$WA_redirectURL "";
  if (
function_exists("rel2abs")) $WA_redirectURL $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
  
$WA_keepQueryString false;
  
$WA_indexField "UserID";
  
$WA_fieldNamesStr "UserImage|UserThumbnail|randomString";
  
$WA_fieldValuesStr "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]  ."" $WA_AB_Split "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]  ."" $WA_AB_Split "".$_SESSION['rpw']  ."";
  
$WA_columnTypesStr "',none,''|',none,''|',none,''";
  
$WA_comparisonStr "=|=|=";
  
$WA_fieldNames explode("|"$WA_fieldNamesStr);
  
$WA_fieldValues explode($WA_AB_Split$WA_fieldValuesStr);
  
$WA_columns explode("|"$WA_columnTypesStr);
  
  
$WA_where_fieldValuesStr "".$_SESSION['SecurityAssist_UserID']  ."";
  
$WA_where_columnTypesStr "none,none,NULL";
  
$WA_where_comparisonStr "=";
  
$WA_where_fieldNames explode("|"$WA_indexField);
  
$WA_where_fieldValues explode($WA_AB_Split$WA_where_fieldValuesStr);
  
$WA_where_columns explode("|"$WA_where_columnTypesStr);
  
$WA_where_comparisons explode("|"$WA_where_comparisonStr);
  
  
$WA_connectionDB $database_mfaccessConn;
  
mysql_select_db($WA_connectionDB$WA_connection);
  @
session_start();
  
$updateParamsObj WA_AB_generateInsertParams($WA_fieldNames$WA_columns$WA_fieldValues, -1);
  
$WhereObj WA_AB_generateWhereClause($WA_where_fieldNames$WA_where_columns$WA_where_fieldValues,  $WA_where_comparisons );
  
$WA_Sql "UPDATE `" $WA_table "` SET " $updateParamsObj->WA_setValues " WHERE " $WhereObj->sqlWhereClause "";
  
$MM_editCmd mysql_query($WA_Sql$WA_connection) or die(mysql_error());
  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);
  }
}
?>



to line 131 so the update is before the recordset.

Sign in to reply to this post

Mysite07430650

Thanks Jason, that worked.

Two sized images are produced by the DFP. One is to appear on userupdate page and the other in another page within the same directory as userupdate page.

I noticed that although the profile image is immediately updated in the userupdate page, the other page only updates after logging out and logging in again. The photo in the other page uses session variable to update. Earlier you suggested resetting session variables and I was wondering whether this is what I need to do to ensure the photo in the other page updates simultaneously as the userupdate page.

Any suggestion?

Thanks!

The code referencing the photo in the other page is:

<?php require_once('../Connections/mfaccessConn.php'); ?>
<?php require_once( "../webassist/security_assist/helper_php.php" ); ?>
<?php
if (!WA_Auth_RulePasses("VerifiedUser")){
WA_Auth_RestrictAccess("userupdate.php");
}
?>
<?php
@session_start();
if (!isset($_SESSION["UserImage"])) {
$_SESSION["UserImage"] = "".$_SESSION['UserImage'] ."";
}
?>
<?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;
}
}
mysql_select_db($database_mfaccessConn, $mfaccessConn);
$query_rsProimage = "SELECT UserID, UserEmail, UserPassword, UserFirstName, UserLastName, UserImage, UserThumbnail FROM pcms2_users ORDER BY UserID ASC";
$rsProimage = mysql_query($query_rsProimage, $mfaccessConn) or die(mysql_error());
$row_rsProimage = mysql_fetch_assoc($rsProimage);
$totalRows_rsProimage = mysql_num_rows($rsProimage);?>
<!DOCTYPE HTML>

And the profile photo:

<div class="profileImage"><img src="../_images/userprofile/<?php echo $_SESSION['UserImage']; ?>" name="cppmf100" width="120" height="120" id="cppmf100"></div>

Sign in to reply to this post

Jason ByrnesWebAssist

On the user update page, add a set session variable behavior to reset the UserImage session variable.

make sure the set session behavior code comes after the recordset, and use the recordset column as the value.

Sign in to reply to this post

Mysite07430650

Originally Said By: Jason Byrnes
  On the user update page, add a set session variable behavior to reset the UserImage session variable.

make sure the set session behavior code comes after the recordset, and use the recordset column as the value.  


Hi Jason,

I tried the suggestion but it is not updating the other page without logging out first and then logging in. I have attached the two files the clien-home page has the larger image that should update simultaneously along with the update that occurred in userupdate page.

Please have a look and tell me what I am doing wrong.

Thanks.

Attached Files
profile-image.zip
Sign in to reply to this post

Jason ByrnesWebAssist

your update page has the same code order problem as before.

the code order is:
recordset
set session value
update record

the order should be:

update record
recordset
set session value

also, on the client-home.php page, you are creating a recordset, why not filter that recordset on the SecurityAssist_UserID session variable, and use the recordset for displaying the image instead of trying to store the file name in a session and change that on update.

Sign in to reply to this post

Mysite07430650

Originally Said By: Jason Byrnes
  your update page has the same code order problem as before.

the code order is:
recordset
set session value
update record

the order should be:

update record
recordset
set session value

also, on the client-home.php page, you are creating a recordset, why not filter that recordset on the SecurityAssist_UserID session variable, and use the recordset for displaying the image instead of trying to store the file name in a session and change that on update.  


Jason, I changed the order of the code as recommended and was able to update the profile photo. However, once I am logged out, I am unable to log in again. Upon checking the users table I found that my password had been wiped out after updating. Clearly this should not happen and I wondering why that is the case.

I should also say that I have two update server behaviours (Please see attached image) in the userupdate page, the first updates the users' table and the second deals with activating verification link for the double opt-in registration.

Should the second also be moved above the recordset or left alone?

Putting the update behaviour above the recordset logged me out of the table?

How do I rectify this?

The last point regarding filtering the recordset on the client-home page, should it have $_SESSION["SecurityAssist_UserID"] or $_SESSION["UserImage"] as the session name?

Sign in to reply to this post

Jason ByrnesWebAssist

Rather than rearranging the update behaviors to change the session variables, set the recordset on the client-home.php page to fdilter using the session:

$_SESSION["SecurityAssist_UserID"]

and use the recordset to populate the image rather than the session

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...