-
-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is procedure to update & display login user table when manually add a table to uf_users #120
Comments
Once you have that working, you can update the API pages: Finally, you'll want to update Let me know if you run into a problem at any of these stages, we can try to walk you through it. |
Can you please check if following code for extra table url correct. Before I implement. Line No. are estimate as some places I might have added extra line space ======= models/db_functions.php =========== //Check if an url exists in the DB ==========> edit line 230 ==========> $query = "select {$db_table_prefix}users.id as user_id, user_name, display_name, email, url, title, sign_up_stamp, last_sign_in_stamp, active, enabled, primary_group_id from {$db_table_prefix}users"; ========== api/register.php ==========
========== api/register.php ========== // POST: user_name, display_name, email, url, title, password, passwordc, [admin, add_groups, skip_activation, csrf_token] ==========> after line 86 add following code ==========> $url = str_normalize($validator->requiredPostVar('url')); ==========> edit line 132 add following code ==========> if ($new_user_id = createUser($user_name, $display_name, $email, $url, $title, $password, $passwordc, $require_activation, $admin)){ ======== api/update_user.php ================= $url = str_normalize($validator->optionalPostVar('url')); ==========> after line 117 add following code ==========> //Update url if specified and different from current value ============= forms/form_user.php ==================
==========> after line 339 add following code ==========>
{{url}}
|
Hang on, I'm confused. Is |
url is a new field in uf_user table |
Ok so if you're trying to check if a url exists, you'd do:
Everything else looks pretty good, just remember that |
Oh and don't forget to update I'll be updating that soon to use |
I have created manually a field url in uf_user table. Then via upload.php I want to upload logo.png and write url in field url whichI want to display in sidebar above dashboard link |
What is the code for post to new url field for logged in user and echo for logged in user |
To load a field into the logged-in user, you'll need to modify |
OK, will play around with code tomorrow writing exams wiil come back with any issues |
Cool, good luck on the exams! |
Just patched it to use |
Thanxs, Alex Got the whole process working, but it works now from the registration page. I don’t want it in the registration page I want the logged in user to upload their logo in their dashboard. I just want to add a form in the dashboard to upload their logo to images directory which I have created within UF and displaying it in dashboard in sidebar Thanxs for the previous help I have used it to add a cellphone number to registration page and it works 100% within db From: Alex Weissman [mailto:[email protected]] Just patched it to use serialize, so you don't need to update the JS anymore. — This email is free from viruses and malware because avast! Antivirus protection is active. |
Nice, glad it's working for you. If you want to create a new form, I would just copy |
I'm running in circles, and maybe it is just something simple to do with session & variables. This is my upload.php file which connect_errno){ echo "Error".$sp->error; } $path="images/"; if(isset($_POST['upload'])) { $path=$path. $_SESSION['user_id'].$_FILES['file_upload']['name']; if(move_uploaded_file($_FILES['file_upload']['tmp_name'],$path)) { echo " ".basename($_FILES['file_upload']['name'])." has been uploaded "; echo ''; $img=$_FILES['file_upload']['name']; ``` $query="insert into uf_users (url, date) values('$img',now())"; if($sp->query($query)){ echo " Inserted to DB also"; }else{ echo "Error ".$sp->error; } ``` } else { echo "There is an error,please retry or ckeck path"; } } ?> |
First of all, don't use |
OK, done updated db_functions.php and api/update_use and remove mysqli_connect in my update.php file Still receive following error Call to a member function query() on a non-object in /home/realesta/public_html/witbank/admin/account/uploadnew.php on line 18 How do I call a query to add the url in my database in my update.php I see you use I use Due to image upload and just wan’t to know how to adjust my code $query="insert into uf_users (avatar, date) values('$img',now())";
} else { echo "There is an error,please retry or ckeck path"; } } This email is free from viruses and malware because avast! Antivirus protection is active. |
The problem is that you're trying to use
|
Thanxs Alex Do I need to add this to my file as per all your files or not: Ok I have tried it with and without and receive following error:- Fatal error: Call to undefined function pdoConnect() in /home/realesta/public_html/witbank/admin/account/uploadnew.php on line 16 Here is my complete uploadnew.php file with your new code "; echo ''; $img=$_FILES['file_upload']['name']; $db = pdoConnect(); $query = "UPDATE uf_users SET avatar = :img, date = NOW() WHERE id = :user_id"; $stmt = $db->prepare($query); $sqlVars = array( ":img" => $img, ":user_id" => $loggedInUser->user_id ); $stmt = execute($sqlVars); ``` if($sp->query($query)){ echo "Inserted to DB also"; }else{ echo "Error ".$sp->error; } ``` } else { echo "There is an error,please retry or ckeck path"; } } ?> From: Alex Weissman [mailto:[email protected]] The problem is that you're trying to use insert, when you should be using update. You need something like: $db = pdoConnect(); — This email is free from viruses and malware because avast! Antivirus protection is active. |
Add global $pdoConnect(); after setrefferalpage.
|
I am not sure if I had to delete rest of line or kept it after adding-: global $pdoConnect(); but still error even If I delete:- (getAbsoluteDocumentPath(FILE)); Parse error: syntax error, unexpected 'global' (T_GLOBAL) in /home/realesta/public_html/witbank/admin/account/uploadtest.php on line 13 New Code "; echo ''; $img=$_FILES['file_upload']['name']; $db = pdoConnect(); $query = "UPDATE uf_users SET avatar = :img, date = NOW() WHERE id = :user_id"; $stmt = $db->prepare($query); $sqlVars = array( ":img" => $img, ":user_id" => $loggedInUser->user_id ); $stmt = execute($sqlVars); ``` if($sp->query($query)){ echo "Inserted to DB also"; }else{ echo "Error ".$sp->error; } ``` } else { echo "There is an error,please retry or ckeck path"; } } ?> From: Bryson [mailto:[email protected]] Add global $pdoConnect(); after setrefferalpage.
— This email is free from viruses and malware because avast! Antivirus protection is active. |
setReferralPage(getAbsoluteDocumentPath(FILE)); global $pdoConnect(); Sorry about that haha I ment like so.
|
@johanvena yes, you always need to include the |
Well I don't think I'll be replying via email anymore gets confusing fast lol. |
Ok, just added but receive following error and image does not upload Parse error: syntax error, unexpected '(', expecting ',' or ';' in /home/realesta/public_html/witbank/admin/account/uploadnew.php on line 35 Line 35 = global $pdoConnect(); If I remove 2 added lines it upload images but gives following error Fatal error: Call to undefined function execute() in /home/realesta/public_html/witbank/admin/account/uploadnew.php on line 56 Line 56 = $stmt = execute($sqlVars); |
I was wondering if you could point me in the right direction to learn user
|
Thanxs, I have missed some steps will go through my code and see which step I have missed |
Ok, the only place I didn't update my code for avatar and date was in models/secure_functions.php |
Well its hard to say without seeing the code, but I noticed you did:
I'd recommend carefully looking through the documentation for PDO: http://php.net/manual/en/book.pdo.php and also following the pattern we use in You can also post your code in a private gist and email me a link, and I can try to take a look. But, please make sure you are understanding the basics of PDO first. |
I have manually add a table to uf_users to hold an url (manually insert a url to see if echo will display using below code).
user_id,'url'); ?>Receive Fatal error: Using $this when not in object context in ............................
Which files do I need to edit? or can I post directly to login user url table or do I need to use ....... action="update_user.php" method="post">
What is the code to update via a form the
url
table for login user andWhat is code to echo table url for login user
Thanxs in advance
The text was updated successfully, but these errors were encountered: