Medios de comunicación - Find jobs - IKA Processing Equipment - Debt Consolidation - Web Hosting

PDA

View Full Version : Simple PHP Code Snippet Needed...I Think !


tryme1
Jan 23rd 2007, 2:49 pm
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>

Anyone got any ideas how to do this ?

noppid
Jan 23rd 2007, 2:55 pm
Do the lead ID after the post instead of before it and use something like.


$lead_id = $_POST['company'] . date("gdmy",time());

tryme1
Jan 23rd 2007, 3:16 pm
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>

smatts9
Jan 23rd 2007, 5:20 pm
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>