Skip to content

Commit

Permalink
adding profile update query changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shreja19 committed Apr 15, 2022
1 parent a528d9a commit 5602571
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 39 deletions.
4 changes: 4 additions & 0 deletions backend/collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
// $item_data = DatabaseConnector::getItem($item_id);
// DatabaseConnector::setPendingApproval($item_id);
break;
case EDIT_PROFILE:
DatabaseConnector::updateUserProfileInfo(USER_ID);
$NOTIFY_USER=TRUE;
break;
case CANCEL_ADD_ITEM:
// $item_id = $_POST["item_id"];
// if($new_item){
Expand Down
2 changes: 1 addition & 1 deletion backend/updateProfile.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php


$data=DatabaseConnector::getCurrentAccountDetails(USER_ID);

?>
6 changes: 3 additions & 3 deletions classes/class.database.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ public static function addEvent($type, $data){
public static function newItemEvent($data){
$q = "INSERT INTO orders (".EVENT_TABLE_ID.",".EVENT_TABLE_TIMESTAMP.",".EVENT_TABLE_STATUS.",".EVENT_TABLE_ITEM_ID.",".EVENT_TABLE_BUYER_ID.",".EVENT_TABLE_SELLER_ID.",".EVENT_TABLE_TRANSACTION_ID.",".EVENT_TABLE_TRANSACTION_AUTHENTICATION_CODE.",".EVENT_TABLE_EVENT_DESCRIPTION.",".EVENT_TABLE_EVENT_TIMESTAMP.") VALUES ()";
self::query($q);
return;
return;
}

/* User Profile update queries
Pre-Populate Form with Current Account Details
*/
public static function getCurrentAccountDetails($id){
$q = 'SELECT fname, lname, email, addr_line1, addr_line2, city, state, zip, phone FROM user WHERE id =' .$id;
$q = 'SELECT fname, lname, email, addr_line1, addr_line2, city, state, zip, phone FROM user WHERE id ='.$id;
return DatabaseConnector::query($q);
}

Expand All @@ -132,7 +132,7 @@ public static function getCurrentAccountDetails($id){
Once User has entered in different values, update the entire row with the new/existing form values
*/
public static function updateUserProfileInfo($data, $user_id){
$q = "UPDATE user SET id=value-1,username=value-2,email=value-3,password=value-4,`admin`=value-5,created_at=value-6,updated_at=value-7,fname=value-8,lname=value-9,addr_line_1=value-10,addr_line_2=value-11,city=value-12,state=value-13,zip=value-14,phone=value-15 WHERE id = $userID";
$q = "UPDATE user SET id=".$user_id.",username=".$_POST[USER_TABLE_USERNAME].",email=".$_POST[USER_TABLE_EMAIL].",password=".$_POST[USER_TABLE_PASSWORD].",fname=".$_POST[USER_TABLE_FNAME].",lname=".$_POST[USER_TABLE_LNAME].",addr_line_1=".$_POST[USER_TABLE_ADDR_LINE_1].",addr_line_2=".$_POST[USER_TABLE_ADDR_LINE_2].",city=".$_POST[USER_TABLE_CITY].",state=".$_POST[USER_TABLE_STATE].",zip=".$_POST[USER_TABLE_ZIP].",phone=".$_POST[USER_TABLE_PHONE]." WHERE id = ".$user_id;
self::query($q);
return;
}
Expand Down
43 changes: 24 additions & 19 deletions frontend/collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,30 @@
include_once('../functions/functions.item.php');
console(json_encode($GLOBALS['url_loc']));

// try{
// switch($GLOBALS['url_loc'][2]){
// case ADD_ITEM:
// alertBox('Notice', 'Please confirm our price and your submission details.');
// drawCollectorAddItem();
// break;
// case ADD_ITEM_CONFIRMATION:
// alertBox('Notice', 'Item submission awaiting approval. The approval process takes 24 to 48 hours.');
// drawItemPage($item_data, TRUE, TRUE, TRUE);
// break;
// case CANCEL_ADD_ITEM:
// alertBox('Notice', 'Item submission request cancelled.');
// break;
// default:
// break;
// }
// } catch(Exception $e){
// alertBox('Error', 'malformed url');
// }
try{
switch($GLOBALS['url_loc'][2]){
case ADD_ITEM:
alertBox('Notice', 'Please confirm our price and your submission details.');
drawCollectorAddItem();
break;
case ADD_ITEM_CONFIRMATION:
alertBox('Notice', 'Item submission awaiting approval. The approval process takes 24 to 48 hours.');
drawItemPage($item_data, TRUE, TRUE, TRUE);
break;
case EDIT_PROFILE:

header("location: /public_html/updateprofile");
break;

case CANCEL_ADD_ITEM:
alertBox('Notice', 'Item submission request cancelled.');
break;
default:
break;
}
} catch(Exception $e){
alertBox('Error', 'malformed url');
}

?>

Expand Down
6 changes: 4 additions & 2 deletions frontend/updateProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

// FRONTEND
include('../functions/functions.edit_profile.php');

drawEditProfile($options);
if(isset ($NOTIFY_USER)){
alertBox('Notice', 'Your profile has been updated successfully.');
}
drawEditProfile($options,$data);


?>
24 changes: 12 additions & 12 deletions functions/functions.edit_profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @return void draws to page
*/
function drawEditProfile($options){
function drawEditProfile($options,$data){

// CONSTANTS
$OPEN_ROW = '<div class="'.FLEX_ROW_JUSTIFY.'">';
Expand All @@ -19,67 +19,67 @@ function drawEditProfile($options){
// ROW USERNAME
echo $OPEN_ROW;
drawLabel('UserName', LISTING_LABEL);
drawTextInput(USER_TABLE_USERNAME, LISTING_INPUT_AREA, 20, TRUE);
drawTextInput(USER_TABLE_USERNAME, LISTING_INPUT_AREA, 20, TRUE, $data[USER_TABLE_USERNAME]);
echo $CLOSE_ROW;

// ROW EMAIL
echo $OPEN_ROW;
drawLabel('Email', LISTING_LABEL);
drawTextInput(USER_TABLE_EMAIL, LISTING_INPUT_AREA, 20, TRUE);
drawTextInput(USER_TABLE_EMAIL, LISTING_INPUT_AREA, 20, TRUE,$data[USER_TABLE_EMAIL]);
echo $CLOSE_ROW;

// ROW PASSWORD
echo $OPEN_ROW;
drawLabel('Password', LISTING_LABEL);
drawTextInput(USER_TABLE_PASSWORD, LISTING_INPUT_AREA, 20, TRUE);
drawTextInput(USER_TABLE_PASSWORD, LISTING_INPUT_AREA, 20, TRUE,$data[USER_TABLE_PASSWORD]);
echo $CLOSE_ROW;

// ROW FIRST NAME
echo $OPEN_ROW;
drawLabel('First Name', LISTING_LABEL);
drawTextInput(USER_TABLE_FNAME, LISTING_INPUT_AREA, 20, TRUE);
drawTextInput(USER_TABLE_FNAME, LISTING_INPUT_AREA, 20, TRUE,$data[USER_TABLE_FNAME]);
echo $CLOSE_ROW;

// ROW LAST NAME
echo $OPEN_ROW;
drawLabel('Last Name', LISTING_LABEL);
drawTextInput(USER_TABLE_LNAME, LISTING_INPUT_AREA, 20, TRUE);
drawTextInput(USER_TABLE_LNAME, LISTING_INPUT_AREA, 20, TRUE,$data[USER_TABLE_LNAME]);
echo $CLOSE_ROW;

// ROW ADDRESS LINE 1
echo $OPEN_ROW;
drawLabel('Address Line 1', LISTING_LABEL);
drawTextInput(USER_TABLE_ADDR_LINE_1, LISTING_INPUT_AREA, 20, TRUE);
drawTextInput(USER_TABLE_ADDR_LINE_1, LISTING_INPUT_AREA, 20, TRUE,$data[USER_TABLE_ADDR_LINE_1]);
echo $CLOSE_ROW;

// ROW ADDRESS LINE 2
echo $OPEN_ROW;
drawLabel('Address Line 2', LISTING_LABEL);
drawTextInput(USER_TABLE_ADDR_LINE_2, LISTING_INPUT_AREA, 20, TRUE);
drawTextInput(USER_TABLE_ADDR_LINE_2, LISTING_INPUT_AREA, 20, TRUE,$data[USER_TABLE_ADDR_LINE_2]);
echo $CLOSE_ROW;

// ROW CITY
echo $OPEN_ROW;
drawLabel('City', LISTING_LABEL);
drawTextInput(USER_TABLE_CITY, LISTING_INPUT_AREA, 20, TRUE);
drawTextInput(USER_TABLE_CITY, LISTING_INPUT_AREA, 20, TRUE,$data[USER_TABLE_CITY]);
echo $CLOSE_ROW;

// ROW STATE
echo $OPEN_ROW;
drawLabel('State', LISTING_LABEL);
drawTextInput(USER_TABLE_STATE, LISTING_INPUT_AREA, 20, TRUE);
drawTextInput(USER_TABLE_STATE, LISTING_INPUT_AREA, 20, TRUE,$data[USER_TABLE_STATE]);
echo $CLOSE_ROW;

// ROW ZIP CODE
echo $OPEN_ROW;
drawLabel('Zip Code', LISTING_LABEL);
drawTextInput(USER_TABLE_ZIP, LISTING_INPUT_AREA, 20, TRUE);
drawTextInput(USER_TABLE_ZIP, LISTING_INPUT_AREA, 20, TRUE,$data[USER_TABLE_ZIP]);
echo $CLOSE_ROW;

// ROW PHONE NUMBER
echo $OPEN_ROW;
drawLabel('Phone Number', LISTING_LABEL);
drawTextInput(USER_TABLE_PHONE, LISTING_INPUT_AREA, 20, TRUE);
drawTextInput(USER_TABLE_PHONE, LISTING_INPUT_AREA, 20, TRUE,$data[USER_TABLE_PHONE]);
echo $CLOSE_ROW;

// ROW SUBMIT BUTTON
Expand Down
4 changes: 2 additions & 2 deletions functions/functions.ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ function drawLabel($text, $format){
* @param bool $required set required flag
* @return void draws to page
*/
function drawTextInput($name, $format, $character_limit, $required){
function drawTextInput($name, $format, $character_limit, $required,$value){
$_c = inputValidationLength($character_limit);
$_r = inputValidationRequired($required);
echo '
<input type="text" name="'.$name.'" class="'.$format.'"'.$_c.$_r.'>
<input type="text" value="'.$value.'" name="'.$name.'" class="'.$format.'"'.$_c.$_r.' >
';
return;
}
Expand Down

0 comments on commit 5602571

Please sign in to comment.