Jump to content

Editing $_POST Array...?


dhcrusoe

Recommended Posts

Hey everyone,

 

A PHP form submit that I have has two fields: a dropdown team/age field (U10,U11) and a "birthyear" field, which in the form is hidden. Unfortunately, the form field names are database-generated in SalesForce (and so, they're weird).

 

On the processing side, the script is supposed to read the TEAM field and edit the YEAR field accordingly. However, it isn't working. Here's what I have:

 

if ($_POST["00N40000001tymD"] == "U9") { $_POST["00N40000001tylU"] = "1999-2000"; }  
if ($_POST["00N40000001tymD"] == "U10") { $_POST["00N40000001tylU"] = "1998-1999"; }
if ($_POST["00N40000001tymD"] == "U11") { $_POST["00N40000001tylU"] = "1997-1998"; }
if ($_POST["00N40000001tymD"] == "U12") { $_POST["00N40000001tylU"] = "1996-1997"; }

 

Maybe there's a better way to accomplish this? Or a reason this method isn't best / doesn't work?

 

Thanks for your thoughts, everyone!

--Dave

Link to comment
https://forums.phpfreaks.com/topic/140677-editing-_post-array/
Share on other sites

Oh -- Sorry!

 

The data field for year is not being overwritten as per the IF statement. Basically, to test, I've assigned a temporary value in the form ("empty") that should be overwritten by the year ("1999-2000") with the IF statement. But for some reason, that isn't happening, and "empty" is being written to the DB.

 

  Quote

What do you mean by "it isn't working". What isn't working? What do you expect to happen?

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/140677-editing-_post-array/#findComment-736228
Share on other sites

Nod... it's a SalesForce integrator, so there's no choice.  Out of curiosity, I tried:

 

$_POST["00N40000001tylU"] = "1999-2000";

 

and that didn't work, either. Any ideas of why it might not be? That might show us why the larger IF isn't overwriting...

 

 

 

  Quote

is your field name, naming scheme set up with names that like? WOW... talk about confusion

Link to comment
https://forums.phpfreaks.com/topic/140677-editing-_post-array/#findComment-736237
Share on other sites

Instead of using the "if" statements, try this:

<?php
$new_vals = array('U9' => '1999-2000', 'U10' => ' 1998-1999', 'U11' => '1997-1998', 'U12' => '1996 -1997')
echo '<pre> ' .print_r($_POST["00N40000001tymD"],true) . '</pre>'; // debug
$_POST['00N40000001tylU'] = (array_key_exists($_POST["00N40000001tymD"],$new_vals))?$new_vals[$_POST["00N40000001tymD"]]:'Bad Key';
echo '<pre> ' .print_r($_POST["00N40000001tylU"],true) . '</pre>'; // debug
?>

 

Ken

 

 

Link to comment
https://forums.phpfreaks.com/topic/140677-editing-_post-array/#findComment-736250
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.