dhcrusoe Posted January 13, 2009 Share Posted January 13, 2009 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 More sharing options...
kenrbnsn Posted January 13, 2009 Share Posted January 13, 2009 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-736218 Share on other sites More sharing options...
dhcrusoe Posted January 13, 2009 Author Share Posted January 13, 2009 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 More sharing options...
dennismonsewicz Posted January 13, 2009 Share Posted January 13, 2009 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-736231 Share on other sites More sharing options...
dhcrusoe Posted January 13, 2009 Author Share Posted January 13, 2009 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 More sharing options...
dennismonsewicz Posted January 13, 2009 Share Posted January 13, 2009 well the only thing i can figure is that the input field name is not correct and therefore not setting to a new variable. have you tried just echoing out the $_POST? Link to comment https://forums.phpfreaks.com/topic/140677-editing-_post-array/#findComment-736239 Share on other sites More sharing options...
kenrbnsn Posted January 13, 2009 Share Posted January 13, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.