Simple PHP Code Snippet Needed...I Think !

Discussion in 'PHP' started by tryme1, Jan 23, 2007.

  1. #1
    OK,

    all I'm trying to do is to capture the input of one form field and add it to another hidden field.

    What I'm trying to do is create a Lead ID out of the company name combined with some date and time information.

    I can pull in the date and time information using the code shown in the hidden field below, but have no idea how to capture the input of the 'Company' field.

    <form  method=POST action="">
    <input type=hidden name="Lead_ID" value="_<?php echo date("gdmy"); ?>"">
    <table border="0" cellspacing="0" cellpadding="3">
    <tr><td align="left" >Name</td>
    <td align=left type="text" name="name"  ></td></tr>
    <tr><td align="left" >Company</td>
    <td align=left><input type="text" name="company"  ></td></tr>
    <tr><td colspan=2 align="left">
    <input type=submit value="Submit"></td></tr>
    </table>
    </form>
    Code (markup):
    Anyone got any ideas how to do this ?
     
    tryme1, Jan 23, 2007 IP
  2. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Do the lead ID after the post instead of before it and use something like.

    
    $lead_id = $_POST['company'] . date("gdmy",time());
    
    PHP:
     
    noppid, Jan 23, 2007 IP
  3. tryme1

    tryme1 Guest

    Messages:
    306
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What do you mean by "do the lead ID after the post instead of before it"

    I've tried this with no success : the lead_ID appears blank :

    <form  method=POST action="">
    <input type=hidden name="Lead_ID" value="_<?php echo date("gdmy"); ?>"">
    <table border="0" cellspacing="0" cellpadding="3">
    <tr><td align="left" >Name</td>
    <td align=left type="text" name="name"  ></td></tr>
    <tr><td align="left" >Company</td>
    <td align=left><input type="text" name="company"  ></td></tr>
    <tr><td colspan=2 align="left">
    <input type=submit value="Submit"></td></tr>
    </table>
    <?php $lead_id = $_POST['company'] . date("gdmy",time()); ?>
    </form>
    Code (markup):
     
    tryme1, Jan 23, 2007 IP
  4. smatts9

    smatts9 Active Member

    Messages:
    1,089
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    88
    #4
    It should work, try echoing the $lead_id, I don't see why it wouldn't output: "companynameTIMEstuff". Try this:
    
    <form  method=POST action="">
    <input type=hidden name="Lead_ID" value="_<?php echo date("gdmy"); ?>"">
    <table border="0" cellspacing="0" cellpadding="3">
    <tr><td align="left" >Name</td>
    <td align=left type="text" name="name"  ></td></tr>
    <tr><td align="left" >Company</td>
    <td align=left><input type="text" name="company"  ></td></tr>
    <tr><td colspan=2 align="left">
    <input type=submit value="Submit"></td></tr>
    </table>
    <?php 
    $lead_id = $_POST['company'] . date("gdmy",time()); 
    echo $lead_id;
    ?>
    </form>
    
    Code (markup):
     
    smatts9, Jan 23, 2007 IP