Page 1 of 1

Putting Random Values into Database

Posted: Sun Aug 03, 2008 5:40 pm
by funkyfela
Helo all. I must appologise if my explanation is not quite clear but, i will try and make it as clear as posible.

in my form i have the following info:

<form id="DiscountMall" name="DiscountMall" method="post" action="transanction.php">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="33%" class="style1">Product Code <br />
<input name="ProductCode" type="text" class="style1" id="ProductCode" /></td>
<td width="36%" class="style1">&nbsp;</td>
<td width="31%" class="style1">&nbsp;</td>
</tr>
<tr>
<td colspan="3" align="center" class="style1">-------------------------------------------------------------------------------------------------------------------------------------------</td>
</tr>
<tr>
<td colspan="3" class="style28">Personal Information </td>
</tr>
<tr>
<td class="style1">First Name:<br />
<input name="Firstname" type="text" class="style1" id="Firstname" /></td>
<td class="style1">Middle Name:<br />
<input name="Middlename" type="text" class="style1" id="Middlename" /></td>
<td class="style1">Surname:<br />
<input name="Surname" type="text" class="style1" id="Surname" /></td>
</tr>
<tr>
<td class="style1">Official Address:<br />
<textarea name="OfficialAddress" rows="3" class="style1" id="OfficialAddress"></textarea></td>
<td class="style1">Billing Address(for delivery):<br />
<textarea name="BillingAddress" rows="3" class="style1" id="BillingAddress"></textarea></td>
<td class="style1">&nbsp;</td>
</tr>
<tr>
<td class="style1">Email:<br />
<input name="Email" type="text" class="style1" id="Email" /></td>
<td class="style1">Phone(Mobile):<br />
<input name="Phone" type="text" class="style1" id="Phone" /></td>
<td class="style1">&nbsp;</td>
</tr>
<tr>
<td colspan="3" class="style1"><input name="Submit" type="submit" class="style1" value="Submit" />
&nbsp;
<input name="Reset" type="reset" class="style1" id="Reset" value="Reset" /></td>
</tr>
<tr>
<td colspan="3" class="style1">&nbsp;</td>
</tr>
<tr>
<td colspan="3" class="style1">&nbsp;</td>
</tr>
</table>
</form>

So, when a user submits the form, a page displays echoing out the form values, on this page i have this code for random number generation as the transaction ID:
DisMall <? echo mt_rand(1,50); echo rand(1,5000); ?>

The problem now is how to get this transaction id into my database (every other data firstname etc.. are in the database, but am not able to put the random number into the database) please how do i do that.
thanks all

Re: Putting Random Values into Database

Posted: Sun Aug 03, 2008 6:23 pm
by ody3307
Create a hidden form element (or 2 if you want the numbers in separate db fields).
Drop the random numbers into variables, then echo the variables to both the screen and to the "value" of your new hidden element(s). You can then access the random numbers from your $_POST variables just like any other value.