Results 1 to 8 of 8

Thread: hidden form field help

  1. #1
    Join Date
    Apr 2007
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default hidden form field help

    Hi everyone!

    I am trying to submit a form and I have 6 hidden fields that I need to populate with the values of the other form fields. I do not have access to the file that is used in the form action.

    Here is what I have so far:

    PHP Code:

    <form action="" method="POST">
    <fieldset>
    <legend>Submission Form</legend>

    <input type=hidden name="oid" value="00D400000009oFt">
    <input type=hidden name="retURL" value="http://thankyou">

    <input  id="company" maxlength="40" name="company" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7Lc']; ?>" />

    <input  id="last_name" maxlength="80" name="last_name" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7KQ']; ?>"/>

    <input  id="phone" maxlength="40" name="phone" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7KL']; ?>"/>

    <input  id="URL" maxlength="80" name="URL" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7KW']; ?>"/>

    <input  id="email" maxlength="80" name="email" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7KM']; ?>"/>

    <input  id="fax" maxlength="40" name="fax" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7KR']; ?>"/>

    <input name="lead_source" type="hidden" id="lead_source" value="form">

    <label>Preferred URL:</label><input name="00N40000002E7KK" type="text"  id="00N40000002E7KK" value="http://www.google.com/" size="20" maxlength="255" /><br>

    <label>Business Name:</label><input  id="00N40000002E7Lc" maxlength="200" name="00N40000002E7Lc" size="20" type="text" /><br>

    <label>Contact Person:</label><input  id="00N40000002E7KQ" maxlength="200" name="00N40000002E7KQ" size="20" type="text" /><br>

    <label>Business Phone Number:</label><input  id="00N40000002E7KL" maxlength="40" name="00N40000002E7KL" onKeyDown="formatPhoneOnEnter(this, event);" size="20" type="text" /><br>

    <label>Business Fax Number:</label><input  id="00N40000002E7KR" maxlength="40" name="00N40000002E7KR" onKeyDown="formatPhoneOnEnter(this, event);" size="20" type="text" /><br>

    <label>Business Address:</label><textarea  id="00N40000002E7KV" name="00N40000002E7KV" type="text" wrap="soft"></textarea><br>

    <label>Business Email Address:</label><input  id="00N40000002E7KM" maxlength="80" name="00N40000002E7KM" size="20" type="text" /><br>

    <label>Business Website:</label><input  id="00N40000002E7KW" maxlength="255" name="00N40000002E7KW" size="20" type="text" /><br>

    <label>Hours of Operation:</label><input  id="00N40000002E7KX" maxlength="200" name="00N40000002E7KX" size="20" type="text" /><br>

    <label>Services:</label><textarea  id="00N40000002E7KS" name="00N40000002E7KS" rows="3" type="text" wrap="soft"></textarea>

    <label>Tags:</label><textarea  id="00N40000002E7LS" name="00N40000002E7LS" rows="3" type="text" wrap="soft"></textarea><br>

    <label>About:</label><textarea  id="00N40000002E7LX" name="00N40000002E7LX" rows="3" type="text" wrap="soft"></textarea><br>

    <input type="submit" name="submit">

      </fieldset>
    </form>
    Any help would really be appreciated. I have been trying to figure this out for a long time!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You didn't tell us what the problem is. The code you posted looks fine. $_POST['NAME'], where NAME is what you called the field in the first form. If those names are right, then so is the form. It should work.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Apr 2007
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am submitting the form to a cms, and the following fields are not being submitted:

    PHP Code:
    <input  id="company" maxlength="40" name="company" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7Lc']; ?>" />

    <input  id="last_name" maxlength="80" name="last_name" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7KQ']; ?>"/>

    <input  id="phone" maxlength="40" name="phone" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7KL']; ?>"/>

    <input  id="URL" maxlength="80" name="URL" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7KW']; ?>"/>

    <input  id="email" maxlength="80" name="email" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7KM']; ?>"/>

    <input  id="fax" maxlength="40" name="fax" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7KR']; ?>"/>
    The rest of the form works fine.

    Thanks for helping!

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The fields are fine. I think it probably has something to do with the names/ids of the fields. By the way, you don't really need ID and name for each, but I guess it won't hurt.
    You will have to figure out what the cms expects, and work with that. You could try to post the cms code here, but it might be a lot of work to change its coding.

    Just to be sure it's all working, you should view your form's source code, to be sure that the php echoes the variables correctly. If the hidden forms are correctly populated, then it is almost surely a question of the cms script not accepting certain values.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Apr 2007
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    After looking at the source code, the hidden fields are not populating. But this is because the user has to enter some text into the fields that are not hidden, in order for the hidden fields to populate. I was assuming that this would happen when the user hits submit.

    For example, the form has a field called "Business Name", now I want the hidden field to populate with whatever the user enters into the Business Name field.

    But it's just not working.

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Then the names of the fields don't match up in what you are echoing with php and what you called the fields in the first form. The code is not wrote. Its use is--go through ALL of your pages and be sure the variable names stay the same. If so, it should work without problems.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Apr 2007
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for helping!

    So there is only one form on one page...it is not being sent to another page, only a thankyou page.

    When I entered in real values instead of php in the hidden fields, the form works perfectly. Like this:

    PHP Code:
    <input  id="company" maxlength="40" name="company" size="20" type="hidden" value="test6-company" />

    <
    input  id="last_name" maxlength="80" name="last_name" size="20" type="hidden" value="test6-lastname"/>

    <
    input  id="phone" maxlength="40" name="phone" size="20" type="hidden" value="test6-phone"/>

    <
    input  id="URL" maxlength="80" name="URL" size="20" type="hidden" value="test6-url"/>

    <
    input  id="email" maxlength="80" name="email" size="20" type="hidden" value="test6-email"/>

    <
    input  id="fax" maxlength="40" name="fax" size="20" type="hidden" value="test6-fax"/> 
    I really think I am using the correct variables in the php. I will show you one example and you can see if it's correct or not. For the first hidden field that is not working I have this:

    PHP Code:
    <input  id="company" maxlength="40" name="company" size="20" type="hidden" value="<?php echo $_POST['00N40000002E7Lc']; ?>" />
    The value 00N40000002E7Lc is the same as the id for the "Business Name" field:
    <label>Business Name:</label><input id="00N40000002E7Lc" maxlength="200" name="00N40000002E7Lc" size="20" type="text" /><br>

    I think I am doing this right. But it is still not working when I am using the php. Any other suggestions?

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    As I've said before, something MUST be wrong with the variable/field names. All of the code works fine.

    I don't understand the naming system for your variables.

    You have php variables (POST variables) that are sent from a PREVIOUS page. POST variables only exist AFTER a form is submitted. On the page receiving the data, $_POST['FIELDNAMEHERE'] will be the value that was submitted from the previous page.
    As such, you are echoing the values from the fields on the PREVIOUS PAGE named "00N40000002E7Lc" and so on.

    Then you have in the second section of your page another set of fields entirely, these named/ID'd according to these same sort of seemingly random strings.

    Maybe you should be doing two steps: 1. submit your original form (the stuff at the bottom of the page), 2. that goes onto the second page and you use the POST values to populate the top form on your page, then submit the final form...?


    I'm not sure what you are trying to do, but there are no errors/typos in the code-- it looks right. Something is just wrong with the logic behind it, and since I'm not sure what the goal is exactly with all of the variables and what should connect to what, I'm not sure how to fix it. But I'd say start by tracking the variables from page to page. A name/id goes to the next page as $_POST['name or id']. Then on that next page you can echo it or do whatever you want. So if you are using $_POST ever, it won't do anything unless you have a form on a previous page.


    If you still don't work it out with this, then I would say you are using a weird page to receive your data-- you should try another way to process your form. You can use a number of free "form mailers" (search google) or write your own. Realistically it might be faster to just write all of the php, rather than try to make this work, if it is that complex... but I'm not sure where the data is supposed to go/come from overall. What is the purpose of the two different parts of the page? The top is random values for named fields, and the bottom is random fields with named values.... I assume these must be related... but how?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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