Making "name"of image the same as "value" where "value" is a variable
<p>So I have a variable ($file) which is the value of an image (PHP workings), this works fine however I need to make the "name" of my checkbox input the same as the "value" because I am trying to input the "name" of the input to a database field the problem being that putting $file as the name of the element sends "array" to the database instead.  I have tried using the attr method but I can't seem to work it properly.</p>

<p>This is what I have so far:</p>

<pre><code> &lt;?php
include 'init.php';

if(!logged_in()) {
    header:'Location: index.php';
    exit();
}

include 'template/header.php';
?&gt;

&lt;h3&gt;Create Page&lt;/h3&gt;

&lt;?php
if(isset($_POST['page_name'])) {
    $page_name = $_POST['page_name'];
    $album_name = $_POST['album_name'];
    $file = $_POST['file'];
    $radio = $_POST['radio'];
    $radio1 = $_POST['radio1'];

    $errors = array();

    if(empty($page_name)) {
        $errors[] = 'Page Name Required';
    } else {

        if(strlen($page_name) &gt; 55) {
            $errors[] = 'Page Name Has A Max Length of 55 Characters';
        }

    }

    if(!empty($errors)) {
        foreach($errors as $error) {
            echo $error, '&lt;br&gt;';
        die(error_message);
        }
    } else {
        create_new_page($page_name, $album_name, $file, $radio, $radio1);
        header('Location: click3.php');
        exit();
    }

}
?&gt;

&lt;br&gt;

&lt;div id=""&gt;
&lt;form action="" method="post"&gt;  
    &lt;label id="info_label"&gt;
        Page Name:
    &lt;/label&gt;
    &lt;br&gt;
    &lt;input type="text" name="page_name"&gt;
&lt;br&gt;
&lt;br&gt;
    &lt;label&gt;
        Publish to Album:
    &lt;/label&gt;
    &lt;br&gt;
        &lt;select name="album_name"&gt;
            &lt;?php
                $albums = get_albums();

                if(empty($albums)) {
                    echo "
                        You do not currently have any albums
                    ";
                } else {
                    foreach($albums as $album) {
                        echo "
                            &lt;option&gt;
                                ".$album['name']."
                            &lt;/option&gt;
                        ";
                    }
                }
            ?&gt;
        &lt;/select&gt;
&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;

&lt;p id="instructions"&gt;Select the images you wish to add to your page.&lt;/p&gt;

&lt;div id="unused_images_selection"&gt;
    &lt;?php
        $user_files_directory = 'uploads/unused_images/'.$_SESSION['user_id'].'/';

        if (file_exists($user_files_directory)) {

        $dir_handle = @opendir($user_files_directory); 

        while ($file = readdir($dir_handle)) { 

        if($file == "." || $file == ".." || $file == "index.php" ) 

        continue; 

            echo "
            &lt;div id=\"image_container\"&gt;
                &lt;div id=\"unused_images_selector\"&gt;
                    &lt;img src=\"uploads/thumbs/unused_images/".$_SESSION['user_id']."/$file\" alt=\"Test\"&gt;
                &lt;/div&gt;
                &lt;div id=\"checkbox\"&gt;
                        &lt;input type=\"checkbox\" name=\"file[]\" value=\"$file\" /&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            "; 
        }
        // Close 
        closedir($dir_handle); 

        } else {
            echo    "&lt;p&gt;
                        You have not uploaded any images.
                    &lt;/p&gt;";
        }
    ?&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p id="instructions"&gt;Select the background image you wish to add to your page.&lt;/p&gt;

&lt;div id="unused_images_selection"&gt;
&lt;?php

$user_files_directory2 = 'background_images/';

        if (file_exists($user_files_directory2)) {

        $dir_handle = @opendir($user_files_directory2); 

        while ($file2 = readdir($dir_handle)) { 

        if($file2 == "." || $file2 == ".." || $file2 == "index.php" ) 

        continue; 

            echo "
            &lt;div id=\"image_container\"&gt;
                &lt;div id=\"unused_images_selector\"&gt;
                    &lt;img src=\"background_images/$file2\" alt=\"Test\" height=\"100px\" width=\"100px\"&gt;
                &lt;/div&gt;
                &lt;div id=\"checkbox\"&gt;
                    &lt;input type=\"radio\" name=\"radio\" value=\"$file2\"&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            "; 
        }
        // Close 
        closedir($dir_handle); 

        } else {
            echo    "&lt;p&gt;
                        Error!  Could not load background images, please refresh or try again later.
                    &lt;/p&gt;";
        }

?&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p id="instructions"&gt;Select the layout which you would like to build your page around.&lt;/p&gt;
&lt;div id="unused_images_selection"&gt;
&lt;?php

$user_files_directory3 = 'layout_styles/';

        if (file_exists($user_files_directory3)) {

        $dir_handle = @opendir($user_files_directory3); 

        while ($file3 = readdir($dir_handle)) { 

        if($file3 == "." || $file3 == ".." || $file3 == "index.php" ) 

        continue; 

            echo "
            &lt;div id=\"image_container\"&gt;
                &lt;div id=\"unused_images_selector\"&gt;
                    &lt;img src=\"layout_styles/$file3\" alt=\"Test\"&gt;
                &lt;/div&gt;
                &lt;div id=\"checkbox\"&gt;
                    &lt;input type=\"radio\" name=\"radio2\" value=\"file3\"&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            "; 
        }
        // Close 
        closedir($dir_handle); 

        } else {
            echo    "&lt;p&gt;
                        Error!  Could not load layout images, please refresh or try again later.
                    &lt;/p&gt;";
        }

?&gt;
&lt;/div&gt;





&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
&lt;center&gt;
    &lt;input type="submit" name="create_page" value="Create Page"&gt;
&lt;/center&gt;
&lt;/form&gt;

&lt;?php
    include 'template/footer.php';
?&gt;
</code></pre>

<p>Any help is greatly appreciated since I have spent about 10 hours trying different techniques etc!</p>

<p>Thanks!</p>
