Insert textfield value into database? (Form)

edited August 2006 in Vanilla 1.0 Help
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.

Comments

  • you need to change
    $Filename = 'SLayoutPic'
    into
    $Filename = "$LayoutPic"
    (note quote marks)
  • edited August 2006
    with " " I now get an error upon submitting the form. Notice: Undefined variable: LayoutPic
  • i should have said that you can drop the quotes entirely. but you're going about this a weird way.
    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.
  • to clarify:
    $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.
  • Yay it works! Great! Thank you so much for your help ithcy! You made my day :D Thank you!
  • glad i could help :D
This discussion has been closed.