redarrow Posted February 14, 2009 Share Posted February 14, 2009 i made this function to post numbers but it does not work. no numbers echo out when posting. the function. <?php function secret_numbers($post_numbers){ $post_numbers=$number1.$number2.$number3.$number4; $num=array("number1","number2","number3","number4"); $numbers=range(0,10); for($i=0; $i<4; $num++, $i++){ echo"<select name='$num[$i]'>"; for($a=0; $a<count($numbers); $a++){ echo" <option value='$numbers[$a]'>{$numbers[$a]}</option>"; } echo"</select>"; } } ?> how i call it <?php echo secret_numbers($_POST['post_numbers']) ?> how i get the info from the form <?php if(isset($_POST['submit'])){ echo "name: {$_POST['username']} <br> password: {$_POST['password']} <br> number{$post_numbers}"; } ?> remember i dont no much about functions can you help cheers. Link to comment https://forums.phpfreaks.com/topic/145206-solved-post-numbers-from-a-function-please-help/ Share on other sites More sharing options...
MadnessRed Posted February 14, 2009 Share Posted February 14, 2009 you code makes very little sense <?php function secret_numbers($post_numbers){ //Line below, what are you trying to do here? you are overwriting the variable $post_numbers, before you have even used it? $post_numbers=$number1.$number2.$number3.$number4; //Whatever you are doign here surely it can be done easier, rahter than $num[$n] how about $number.($n+1) $num=array("number1","number2","number3","number4"); $numbers=range(0,10); for($i=0; $i<4; $num++, $i++){ echo"<select name='$num[$i]'>"; for($a=0; $a<count($numbers); $a++){ echo" <option value='$numbers[$a]'>{$numbers[$a]}</option>"; } echo"</select>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/145206-solved-post-numbers-from-a-function-please-help/#findComment-762209 Share on other sites More sharing options...
redarrow Posted February 14, 2009 Author Share Posted February 14, 2009 what the function looks like not working mate <?php function secret_numbers(){ $num=array("number1","number2","number3","number4"); $numbers=range(0,10); for($i=0; $i<4; $num++, $i++){ echo"<select name='$num[$i]'>"; for($a=0; $a<count($numbers); $a++){ echo" <option value='$numbers[$a]'>{$numbers[$a]}</option>"; } echo"</select>"; } } ?> call it. <?php if(isset($_POST['submit'])){ echo $POST['number1']; $post_numbers=$number1.$number2.$number3.$number4; echo "name: {$_POST['username']} <br> password: {$_POST['password']} <br> number{$_POST['post_numbers']}"; } ?> in the form <?php echo secret_numbers() ?> Link to comment https://forums.phpfreaks.com/topic/145206-solved-post-numbers-from-a-function-please-help/#findComment-762212 Share on other sites More sharing options...
marcus Posted February 14, 2009 Share Posted February 14, 2009 <?php function secret_numbers() { $num = array("number1", "number2", "number3", "number4"); $numbers = range(0, 10); for ($i = 0; $i <= 3; $i++) { echo "<select name=\"" . $num[$i] . "\">\n"; for ($j = 0; $j <= count($numbers) - 1; $j++) { echo "<option value=\"" . $numbers[$j] . "\">" . $numbers[$j] . "</option>\n"; } echo "</select><br>\n"; } } secret_numbers(); ?> worked for me. Link to comment https://forums.phpfreaks.com/topic/145206-solved-post-numbers-from-a-function-please-help/#findComment-762218 Share on other sites More sharing options...
redarrow Posted February 14, 2009 Author Share Posted February 14, 2009 got it working as well but thank you. Link to comment https://forums.phpfreaks.com/topic/145206-solved-post-numbers-from-a-function-please-help/#findComment-762224 Share on other sites More sharing options...
MadnessRed Posted February 14, 2009 Share Posted February 14, 2009 what are you trying to do with this function? Link to comment https://forums.phpfreaks.com/topic/145206-solved-post-numbers-from-a-function-please-help/#findComment-762227 Share on other sites More sharing options...
redarrow Posted February 14, 2009 Author Share Posted February 14, 2009 The function is for users, to post there special number in 4 digits. I give them the secret number when they join stops spam and bots. also let me see who doing what with a log system. Link to comment https://forums.phpfreaks.com/topic/145206-solved-post-numbers-from-a-function-please-help/#findComment-762230 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.