Jump to content

Multidimensional arrays via post.


MrSean

Recommended Posts

Hello there I'm new and quite stuck.  :shrug:

 

So here we go!

 

I have the following HTML form.

<form method="post" action="/Install/Step02/">
  Server: <input type="text" name="MySQL[server]" /><br />
  Database: <input type="text" name="MySQL[Databaser]" /><br />
</form>

 

Now to my understanding I should receive something along the lines of $_POST['MySQL']=>array();.

But instead I get an empty string.

 

Why is this?

           

Link to comment
https://forums.phpfreaks.com/topic/227214-multidimensional-arrays-via-post/
Share on other sites

sounds correct

this is the basic idea

<form method="post" action="">
  Server: <input type="text" name="MySQL[server]" /><br />
  Database: <input type="text" name="MySQL[Databaser]" /><br />
  <input type="submit" name="send" value="send" /><br />
</form>
<?php
echo $_POST['MySQL']['Server'];
echo $_POST['MySQL']['Databaser'];

Well that code isn't secure either,

personally I escape per query

 

however if your happy with it you can simply update to this

 

function recursive_escape(&$value) {
    if (is_array($value)){
        array_map('recursive_escape', $value);
    }else{
        $value = mysql_real_escape_string($value);
    }
}

array_map('recursive_escape', $_POST);

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.