Jump to content

mofm

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Everything posted by mofm

  1. Edit you post and use the tags provided plz
  2. Cross pollinate is a confusing term :S? don't worrie about the two foreach statements cross pollinating what ever that means Just rember if you need to keep any data from the foreach statement you need to store it in a unique variable. The scope of a foreach statement is just like an if statement. The variables are not lost when the for each statement executes but the nature of the statement means that $questionID and $response will only contain data that is in the last element of the array. I hope that makes sense I think you have gotten very confused somewhere. name="answerArray[1]" <------ will not make it an array all you have done here is named it answerArray[1] so in php if you want to access its data you would need to do this $_POST['answerArray[1]'] I dont bealive you can post an array to php using html. If you can id like to know about it:) but what you can do is something like this. name=var value="1;2;3;4;5;6;7;8;9;10" <?php $array=explode(';',$_POST['var']); $echo $array[6];//7 ?>
  3. I have no idea what you are asking and i don't think anyone else will, try rewording your question.
  4. Im not sure on what your asking help on :S ? But i will give it a go A foreach loop is used to loop through arrays and nothing else. If you do not want the key values you can just do this foreach ($array as $value) { //stuff u want to do here } Your code is slightly confusing you seem to be using $_POST['answerArray'] as an array. Im assuming you have modified the global variable somewhere else. If not then $_POST['answerArray'] will be a string and not an array.
  5. Hello, i am starting a large project that another developer will also be working on. What is the best way about doing this. There seems to be a lot of solutions online but a lot of them seem very difficult to setup and maybe even abit over kill. so im kinda after some reasonable suggestions. Thanks mofm
  6. Ok to fully understand what's going on here you must understand that when you pass a variable by reference you are not sending the data contained within that variable but instead sending an address of memory where the data you want is located... this is very different then just sending data. When a function executes you must understand that it has a certain level of scope, ie it cant see/edit variables out side of its { } but if you pass a variable as a reference you allow the function to directly edit a piece of memory. Let me explain with a few examples Example 1 The basics of a function <?php $a=10; $b=addOne($a); // this is simple and you should understand this echo $a; //10 echo $b; //11 function addOne($var) { return $var ++; // This function cant directly edit $a as it is outside its scope so instead we must "return" the data from the variable } ?> Example 2 Using example 1 but instead passing $a as reference. <?php $a=10; addOne(&$a); // I pass $a as a reference using & echo $a; //11 function addOne($var) // now var doesn't contain 10 but instead it contians the location of $a { $var ++; // this is like doing $a++ but it goes through $var inorder to access $a } I hope this helps you get your head round this, its not that hard like anything in php once you get the concept
  7. Although you can just use JS, I think the OP will benefit more from learning AJAX.
  8. You brain + Google will at least get you started buddy. If your not interested in giving it a shot no one else will for you.
  9. ok u need to use ajax to do what u want. have a look at http://www.w3schools.com/PHP/php_ajax_database.asp to get you started with ajax
  10. Although its Solved it does not really help u out that much . Have a look at substr() http://php.net/manual/en/function.substr.php some light reading: http://www.tizag.com/phpT/php-string-strpos.php
  11. http://php.net/manual/en/function.explode.php Explode splits a string into an array e.g. <?php $string="1&2&3&4&5&6&7"; $array=explode("&",$string); ?> Array will be 7 in lenght containg 1 2 3 4 5 6 7 so ur example would be <?php $data = "page=1&data=1:21;2:34;5:57&a=yes"; $array=explode(";",$data): //array[0] will be 1:21 //array[1] will be 2:34 //ect u get the idea, it simple from then on. //just loop though the array do as u wish then use implode to join them back to string if needed. foreach ($array as $k => $v) { // do what u want to the data here } $string=implode($array); ?> Notes on implode http://php.net/manual/en/function.implode.php ; If u want to remove elements from an array you can use unset($array[4]). http://php.net/manual/en/function.unset.php
  12. Yhe i agree with above your best bet is to make page views time out ... this will make inaccuracy's but will still work .. could this be done with ajax ?? im assumption is that it can but im no java-script expert
  13. OK some people seem to think you can make a website 100% secure ..... you can't all you do its make it harder. What your asking is how do i let my code know if a users cookies have been sniffed. All you can really do is check it against the IP/user agent etc etc witch can all be faked one way or another. If this isn't secure enough for you your next port of call is using encryption for all pages on your site this may be unpractical. The overheads of encryption can cause a lot of issues. And even then this isn't secure against man in the middle attacks so...... make your choice choose whats best for your situation and not necessarily the most secure. Today's encryption would take a ridiculously long time to crack its not really a viable option. man in the middle attacks are properly the option an hacker would go for. Mofm
×
×
  • 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.