chard Posted September 30, 2007 Share Posted September 30, 2007 Hi me again Not sure what I'm doing wrong here but what's meant to happen is: if a $_POST isset do this { OK that works but what happens is when i do the echo foreach( $value as $to => $number){ echo $number . '<br>'; } It echos as if every $_POST is set. Maybe I'm checking if post is set incorrectly? Any help would be appreciated. <?php foreach ($_POST as $set => $confirm) { if (isset($confirm)) { $_POST['name1'] = '01'; $_POST['name2'] = '02'; $_POST['name3'] = '03'; $_POST['name4'] = '04'; $_POST['name5'] = '05'; foreach($_POST as $key => $value[]) { $$key = $value; } foreach( $value as $to => $number){ echo $number . '<br>'; } } } ?> <form name="frmsms" value="sms.php" method="POST"> <label>name1 <input type="checkbox" name="name1" value="name1"></label><br> <label>name2 <input type="checkbox" name="name2" value="name2"></label><br> <label>name3 <input type="checkbox" name="name3"></label><br> <label>name4 <input type="checkbox" name="name4"></label><br> <label>Frank <input type="checkbox" name="name5"></label><br> <input type="submit" value="submit"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/71231-echoing-wrong-information/ Share on other sites More sharing options...
jd2007 Posted September 30, 2007 Share Posted September 30, 2007 can u tell us what your code does here: foreach ($_POST as $set => $confirm) { if (isset($confirm)) { $_POST['name1'] = '01'; $_POST['name2'] = '02'; $_POST['name3'] = '03'; $_POST['name4'] = '04'; $_POST['name5'] = '05'; and here: foreach($_POST as $key => $value[]) { $$key = $value; } and here: foreach( $value as $to => $number){ echo $number . '<br>'; } Quote Link to comment https://forums.phpfreaks.com/topic/71231-echoing-wrong-information/#findComment-358286 Share on other sites More sharing options...
chard Posted September 30, 2007 Author Share Posted September 30, 2007 #1 Put the values of every $_POST into $confirm and if $confirm is set assign values to posts whether they exist. #2 For every $_POST put the name into $value and create a variable that corresponds to the $_POST's name #3 Seems very pointless as i look at it now possibly better solution? for ($i = 1; $i <6; $i++) { echo $value[$i] . '<br>'; } Quote Link to comment https://forums.phpfreaks.com/topic/71231-echoing-wrong-information/#findComment-358299 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.