Heya!
My apologies in advance if this is not the right place to post this. Hmm, I'm not sure how to word it right but I'll try my best.
So, there is a particular custom profile field I would like my users to edit, but I want them to edit that profile field on a different page instead of the "Edit Profile" page on the User Control Panel.
I do have my own PHP page set up, thanks to
Infranight's "Comprehensive Guide to Custom Page Creation" tutorial, and I do understand a bit of PHP (mostly stuff like variables and if conditions).
So yeah, I'm wondering, how would I go about doing that? :o
Fill in the value into the DB?
Heya! I'm afraid I'm a bit lost when it comes to this, my apologies.
How?
Do a HTML <form> and get the value via php.
Fill in the value into db with a simple query:
$query = "INSERT INTO mybb_userfields (fid1) VALUES ("$_POST[value]") WHERE uid = $mybb->user[uid]";
Please note that this is just an example that should show how it basically works, you do need to escape the $_POST result of course (use strip_tags and so on, secure it!) and I guess I do have syntax errors in here but I'm too tired to work on this now.
I hope you can figure it out.
Kind regards
Lennart Sauter
Hmm, oh man, I feel really bad when I say this but I can't figure it out.
If you don't mind me asking, could you show me an example of how it's used so I could learn from it?
Also, thanks for helping out.
PK8, here's an example of how you can do it. Please don't use it though, just use it as a base...
if($mybb->request_method == "post")
{
// When the form is submitted, excute the code below
$status = trim($mybb->input['status']); // Clean whitespace from the box
if(!$status)
{
// The user didn't enter anything, so throw an error
error("You didn't enter anything into the required field. Please go back and try again.");
}
// Update the "status" profile field
$update_array = array(
"fid4" = $db->escape_string($status)
);
$db->update_query("userfields", $update_array, "ufid = '".$mybb->user['uid']."'");
// Now that we've updated the database, redirect the user
// The below will appear as a friendly redirect thingy
redirect("index.php", "Thanks for updating your profile status!");
}
<form name="input" action="index.php" method="post">
Status: <input type="text" name="status" />
<input type="submit" value="Submit" />
</form>
Whoa, thanks a bunch, Tomm M!