Results 1 to 10 of 10

Thread: Prefilled (non changeable) php form?

  1. #1
    Join Date
    Jan 2008
    Posts
    141

    Default Prefilled (non changeable) php form?

    Hello!

    I've been looking into making all links connected to a real user. My website only accept registered users to add links. What I was wondering is, if anyone here know how to do the following task:

    In the add.php page, I would like to have the Contact name automatically filled out, for example like this: "Enter your contact name here"

    But instead of "Enter your contact name here" I would like the script to (some how possible?) grab the username (since the user is logged in) and then prefill the username. Then, not only will it prefill the username, but also make it impossible to edit what's been prefilled.

    Example:

    User "jack" goes to add.php page. The script gets his username and enter it automatically in the "Contact name" field. Now it says "jack" next to "Contact name". Also, the field is not possible to edit . He has to submit the form, and there is no way he can change the contact name.

    The reason I need this is to know for sure, that this user added the link.

    Possible?

  2. #2
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    yes, its possible.

    you need to hack the add.php file a small bit, somewhere you need to ask for the username :

    $username = $_COOKIE["username"];

    then look up all the details for the user in the database.

    Assign the details to variables, and then pass them to the template where you jsut use smarty tags to prefill the info.
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  3. #3
    Join Date
    Jan 2008
    Posts
    141

    Default

    Hi,

    I added the code to add.php, but what do you mean with looking up all the details for the user in the database and assigning details to variables?

    I tried adding <%$username%> to my add page but nothing appeared.

  4. #4
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    just before the DisplayTemplate function in add.php ( about line 168 ) add

    Code:
    $contact_name=$_SESSION['indexu_session_username'];
    DisplayTemplate($theme_path . "add_form.html",
    then in add_form.html change the contact line

    Code:
    <input id="contact_name" type="text" name="contact_name" size="40" readonly
     value="<%$contact_name%>" />


    .
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  5. #5
    Join Date
    Jan 2008
    Posts
    141

    Default

    Thank you so much!!! It works perfect!!!

  6. #6
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    Quote Originally Posted by Warz View Post
    Hi,

    I added the code to add.php, but what do you mean with looking up all the details for the user in the database and assigning details to variables?

    I tried adding <%$username%> to my add page but nothing appeared.
    that would have worked too. just needed a little more coding.


    .
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  7. #7
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    I didnt realise username was an available variable... that said my solution would enable you to fill in email and whatever items they entered into the "profile" page... i was thinking you wanted to add things like the phone number and homepage, but thats a bit more work
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  8. #8
    Join Date
    Jan 2008
    Posts
    141

    Default

    Is there any way to make e-mail like this too? I tried, but it only appear with an empty field...

  9. #9
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    Quote Originally Posted by Warz View Post
    Is there any way to make e-mail like this too? I tried, but it only appear with an empty field...
    when the user logins, the only the user name is captured, not the email.

    just before the DisplayTemplate line in the ShowFormAddUrl function

    Code:
    // mod
    	global $email;
    	$users_obj = new clsUsers;
    	$users_obj->table_name = "idx_users";
    	$email=$users_obj->GetEmailAddress($_SESSION['indexu_session_username']);
    // mod
    
        DisplayTemplate($theme_path . "add_form.html","\$email, etc etc


    .
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  10. #10
    Join Date
    Jan 2008
    Posts
    141

    Default

    Excellent!! Thanks a lot

    Looks like this now, worked for me:
    Code:
    $contact_name=$_SESSION['indexu_session_username'];
    // mod
    	global $email;
    	$users_obj = new clsUsers;
    	$users_obj->table_name = "idx_users";
    	$email=$users_obj->GetEmailAddress($_SESSION['indexu_session_username']);
    // mod
        DisplayTemplate($theme_path . "add_form.html","\$error_msg,\$title,\$url,\$description,\$category,\$contact_name,\$email,\$cat,\$add_cat1,\$add_cat2,\$keywords,\$reciprocal_url,\$custom_field_form,\$sponsored_listing_period,\$premium_listing_period,\$basic_listing_price,\$currency_symbol,\$available_payment_systems"
                          . $custf);
      }

Similar Threads

  1. Form Processing
    By echo@ in forum v5.x
    Replies: 11
    Last Post: 12-09-2007, 01:32 PM
  2. login form
    By mighty_falcon in forum v5.x
    Replies: 2
    Last Post: 02-15-2005, 09:32 PM
  3. Postdata in Add form
    By manuel_pr in forum v5.x
    Replies: 1
    Last Post: 01-23-2004, 11:11 AM
  4. v4 db/template form
    By persut in forum v5.x
    Replies: 1
    Last Post: 08-02-2003, 03:32 AM
  5. Any form without reaction
    By cymac in forum v5.x
    Replies: 2
    Last Post: 06-25-2003, 06:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •