Nomb
02-25-2003, 03:35 AM
Hey, I've put a profile field in my index.php. It displays custom profile field #6.
I'd like to be able to choose something from the dropdown, then update the database with the selection, and finally be redirected back to index.php.
Here's what I did to index.php:
$profilefield=$DB_site->query_first("SELECT title,description,required,hidden,maxlength,size,d isplayorder,editable,type,options
FROM profilefield
WHERE profilefieldid=6");
$TheField="";
$optionlines = explode(',', $profilefield[options]);
$option_bit=$optionlines[0];
$TheField = "<select size=\"$profilefield[size]\" name=\"action\" onchange=\"document.updatematrixform.submit();\">";
while ($option_bit) {
$option_bit=trim($option_bit);
if ($option_bit == $bbuserinfo[field6]) { $LocOn = "selected"; } else { $LocOn = ""; }
$TheField .= "<option value=\"$option_bit\" $LocOn>$option_bit</option>";
$option_bit=next($optionlines);
}
$TheField .= "</select>";
if ($HTTP_POST_VARS['action']=="updatematrix") {
$templatesused = 'redirect_updatethanks';
include("./global.php");
$DB_site->query("UPDATE userfield SET field6=$bbuserinfo[field6] WHERE userid=$bbuserinfo[userid]");
eval("standardredirect(\"".gettemplate("redirect_updatethanks")."\",\"index.php?s=$session[sessionhash]\");");
}
The first part of that code works like a charm. I edited it a little but it is from Mutt's hack to create Dropdown fields. Anyway, this generates a dropdown with the correct fields and displays the correct current state of the [field6]. I think it's the second part of the code that's screwed up. :(
This is my forumhome_logoutcode template where I want this field to show up:
<form action="index.php" name="updatematrixform" method="post">
$TheField
<input type="hidden" name="action" value="updatematrix">
</form>
Anyway, the field shows up but I don't know how to update the database and redirect back to index.php.
Any help would be awesome, or just a hint.
Thanks :)
I'd like to be able to choose something from the dropdown, then update the database with the selection, and finally be redirected back to index.php.
Here's what I did to index.php:
$profilefield=$DB_site->query_first("SELECT title,description,required,hidden,maxlength,size,d isplayorder,editable,type,options
FROM profilefield
WHERE profilefieldid=6");
$TheField="";
$optionlines = explode(',', $profilefield[options]);
$option_bit=$optionlines[0];
$TheField = "<select size=\"$profilefield[size]\" name=\"action\" onchange=\"document.updatematrixform.submit();\">";
while ($option_bit) {
$option_bit=trim($option_bit);
if ($option_bit == $bbuserinfo[field6]) { $LocOn = "selected"; } else { $LocOn = ""; }
$TheField .= "<option value=\"$option_bit\" $LocOn>$option_bit</option>";
$option_bit=next($optionlines);
}
$TheField .= "</select>";
if ($HTTP_POST_VARS['action']=="updatematrix") {
$templatesused = 'redirect_updatethanks';
include("./global.php");
$DB_site->query("UPDATE userfield SET field6=$bbuserinfo[field6] WHERE userid=$bbuserinfo[userid]");
eval("standardredirect(\"".gettemplate("redirect_updatethanks")."\",\"index.php?s=$session[sessionhash]\");");
}
The first part of that code works like a charm. I edited it a little but it is from Mutt's hack to create Dropdown fields. Anyway, this generates a dropdown with the correct fields and displays the correct current state of the [field6]. I think it's the second part of the code that's screwed up. :(
This is my forumhome_logoutcode template where I want this field to show up:
<form action="index.php" name="updatematrixform" method="post">
$TheField
<input type="hidden" name="action" value="updatematrix">
</form>
Anyway, the field shows up but I don't know how to update the database and redirect back to index.php.
Any help would be awesome, or just a hint.
Thanks :)