I have a reservation form, where one value (credit card number) needs to be run through an encryption script then get posted to the DB where all of the other fields do not need encryption. Everything is posting over just fine right now to the DB. I would like to encrypt the CC# with the script at the bottom of the page. I got the script from PHPCLASSES.ORG
Expand|Select|Wrap|Line Numbers
- <tr id="tr1">
- <td class="t1" colspan="2">
- Is your mailing address same as your billing address?
- <input name="addr_copy" type="checkbox" onClick="
- copyConditional(this,
- this.form.strasse,
- this.form.baddress);
- copyConditional(this,
- this.form.ort,
- this.form.bcity);
- copyConditional(this,
- this.form.stadt,
- this.form.bstate);
- copyConditional(this,
- this.form.plz,
- this.form.bzip);
- ">
- </td>
- </tr>
- <tr id="tr1">
- <td class="t1">
- <? echo $t_forms['card_type'] ?> <br />
- <select name="card_type" size="1"><!--Maximal Zehn Zeichen-->
- <option<?php if ($card == "") echo " selected"?>></option>
- <option<?php if ($card == 1) echo " selected"?>><?echo $t_pay['amex']?></option>
- <option<?php if ($card == 2) echo " selected"?>><?echo $t_pay['carte']?></option>
- <option<?php if ($card == 3) echo " selected"?>><?echo $t_pay['diners']?></option>
- <option<?php if ($card == 4) echo " selected"?>><?echo $t_pay['jcb']?></option>
- <option<?php if ($card == 5) echo " selected"?>><?echo $t_pay['mc']?></option>
- <option<?php if ($card == 6) echo " selected"?>><?echo $t_pay['visa']?></option>
- </select>
- </td>
- <td class="t1">
- <? echo $t_pay['cc_num'] ?><br> <input <?php echo "value=\"$cc_num\""?> name="cc_num" size="30" maxlength="20" <?echo $schreiben?>>
- </td>
- </tr>
- <tr id="tr1">
- <td class="t1">
- <? echo $t_pay['cc_exp'] ?><br> <input <?php echo "value=\"$cc_exp\""?> name="cc_exp" size="30" maxlength="20" <?echo $schreiben?>>
- </td>
- <td class="t1">
- <? echo $t_pay['cc_ccv'] ?><br> <input <?php echo "value=\"$cc_ccv\""?> name="cc_ccv" size="30" maxlength="20" <?echo $schreiben?>>
- </td>
- </tr>
- <tr id="tr1">
- <td class="t1">
- <? echo $t_pay['b_name'] ?><br> <input <?php echo "value=\"$bname\""?> name="bname" size="30" maxlength="30" <?echo $schreiben?>>
- </td>
- <td class="t1">
- <? echo $t_pay['c_name'] ?><br> <input <?php echo "value=\"$cname\""?> name="cname" size="30" maxlength="30" <?echo $schreiben?>>
- </td>
- </tr>
- <tr id="tr1">
- <td class="t1">
- <? echo $t_pay['b_address']?><br> <input <?php echo "value=\"$baddress\""?> name="baddress" size="30" maxlength="40" <?echo $schreiben?>>
- </td>
- <td class="t1">
- <? echo $t_pay['b_city'] ?><br> <input <?php echo "value=\"$bcity\""?> name="bcity" size="30" maxlength="40" <?echo $schreiben?>>
- </td>
- </tr>
- <tr id="tr1">
- <td class="t1">
- <? echo $t_pay['b_state'] ?><br> <input <?php echo "value=\"$bstate\""?> name="bstate" size="10" maxlength="10" <?echo $schreiben?>>
- </td>
- <td class="t1">
- <? echo $t_pay['b_zip'] ?><br> <input <?php echo "value=\"$bzip\""?> name="bzip" size="30" maxlength="7" <?echo $schreiben?>>
- </td>
- </tr>
Expand|Select|Wrap|Line Numbers
- <?
- include('clsencrypt.php');
- // Create a new Encryption Object
- $enc = new Encryption;
- $encstr = '';
- $decstr = '';
- if (isset($_POST['encrypt'])) {
- $key = $_POST['keystr'];
- // Encrypt the Source Text
- $encstr = $enc->encrypt($key, $_POST['text']);
- } elseif (isset($_POST['decrypt'])) {
- $encstr = $_POST['enctext'];
- $key = $_POST['keystr'];
- // Decrypt the Encrypted Text
- $decstr = $enc->decrypt($key, $_POST['enctext']);
- }
- ?>
- <FORM action = '<?php echo $_SERVER['PHP_SELF'] ?>' method = 'post'>
- <BR>Original Text<BR>
- <TEXTAREA name = 'text' cols="40" rows="1" wrap="soft"></TEXTAREA>
- <BR>Enter Key String<BR>
- <INPUT name = 'keystr' type = 'text' value = ''>
- <BR><Input type='submit' value = 'Encrypt' name='encrypt'><Input type='submit' value = 'Decrypt' name='decrypt'>
- <input type='reset' name='reset' value='Clear Entries'>
- <BR>Encrypted Text<BR>
- <TEXTAREA name = 'enctext' cols="40" rows="1" wrap="soft"><?php
- if (isset($_POST['encrypt']) || isset($_POST['decrypt']))
- echo $encstr;
- ?></TEXTAREA>
- <BR>Decrypted Text<BR>
- <TEXTAREA name = 'dectext' cols="40" rows="1" wrap="soft"><?php
- if (isset($_POST['encrypt']) || isset($_POST['decrypt']))
- echo $decstr;
- ?></TEXTAREA>
- </FORM>