Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Insert textfield value into database? (Form)
Hey guys, I was wondering if I could pop this question to you. I am no expert when it comes to PHP programming but I do know my way around. I am working on a small extension for my forum and I ran into a slight probelm. Maybe its just my pure stupidity and my head isnt thinking, so I was wondering if someone could shine some light on this.
I have a form on one of the extension pages with a textfield like this:
<input name="LayoutPic" id="LayoutPix" type="text" value=""/>
I have created a new field in the database in the user table called LP. Now when the form is submitted, I want whatever the value in LayoutPic is to be inserted into the LP field for this user. I did try something like this:
$Filename = '$LayoutPic';
$UpdateUser = false;
$User->Icon = $Context->Configuration['BASE_URL'] . $Context->Configuration['IMAGES_PATH'] . $Filename;
$UserManager->SaveIdentity($User);
While this does work, it inserts 'http://address/to/my/vanilla/images/$LayoutPic' into the LP field rather than 'http://address/to/my/vanilla/images/imgname.gif' (where imgname is whatever the value of the text field in the form). I'd appreciate if someone could come to an assistance and help me out with this, as I said I am no pro and this is probably something simple but I just can't get it.
0
This discussion has been closed.
Comments
$Filename = 'SLayoutPic'
into
$Filename = "$LayoutPic"
(note quote marks)
if you've already got $LayoutPic, why do you need to copy it into another variable ($Filename) ?
why not just do this:
$User->Icon = $Context->Configuration['BASE_URL'] . $Context->Configuration['IMAGES_PATH'] . $LayoutPic; ?
but first you need to get the variable $LayoutPic from the form field. try this:
$LayoutPic = ForceIncomingString("LayoutPic","");
before the other stuff. and drop the $Filename line.
$LayoutPic = ForceIncomingString("LayoutPic","");
$UpdateUser = false;
$User->Icon = $Context->Configuration['BASE_URL'] . $Context->Configuration['IMAGES_PATH'] . $LayoutPic;
$UserManager->SaveIdentity($User);
instead of what you've got up there.