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
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'];

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.