I've got a form that on submit two things occur:

1. all the data is passed to a shopping cart (a php script)
2. it emails me all the data (using a separate php form-to-email script)

In the form-to-email script, I want to delete/strip/remove some of the data that is being emailed to me.

The form fields look like this:

<input type="text" name="First_Name">
<input type="text" name="Last_Name">
<input type="text" name="Phone">
<input type="checkbox" name="item_1" value="REGFEE-1">
<input type="checkbox" name="item_2" value="REGFEE-2">
<input type="checkbox" name="item_3" value="REGFEE-3">

I want to strip out all the "checkbox" fields from the email it sends me.

How to do?

Member Avatar

diafol

You mention stripping out. Are you including these fields already?

$text = "Firstname: " . addslashes(htmlentities($_POST['First_Name')) . " Lastname: " .  addslashes(htmlentities($_POST['Last_Name')) . " Phone: " . addslashes(htmlentities($_POST['Phone'));

So you don't need to strip out anything.

If you are trying to remove some of the data being mailed to you that you do not want or need you can simply remove references to their variable in the script that does the e-mailing. If you post the code of the e-mailing functions we can have a better look and tell you what to remove so that you'll receive only what you want.

You should remove references to "item_1", "item_2" and "item_3". So if the mailing script's code has something like:

$item_1 = $_POST['item_1'];
$item_2 = $_POST['item_2'];
$item_3 = $_POST['item_3'];

And in the mail function you see it sending "$item_1", "$item_2" and "$item_3" just remove those variables and then it should mail you only their first and last names and phone number as entered into the form.

Thanks for replying guys.

Took some doing but I got it working. There was already a list of "reserved keys" in the mail script:

$reserved_keys[] = "recipient";
$reserved_keys[] = "subject";
and so on....

So I just added those to the list:

$reserved_keys[] = "recipient";
$reserved_keys[] = "subject";
$reserved_keys[] = "item_1";
$reserved_keys[] = "item_2";
$reserved_keys[] = "item_3";

And it does what I want.

Thanks again.

James

Member Avatar

diafol

Thanks for marking as solved James - that's my 1000th solved! Yay!