passing variable value php -


there 2 pages , 1 main , other included it

the main page

<?php $var_value = 7; $_session['varname'] = $var_value; include 'upload_image.php'; ?> 

and included page

<?php include 'init.php';  if (!logged_in()) { header('location: index.php'); exit(); }   include 'template/header.php';   ?>  <h3>upload image</h3>  <?php  if (isset($_files['image'], $_post['image_n'], $_post['image_description'])) { $image_name = $_files['image']['name']; $bytes = $_files['image']['size']; $image_temp = $_files['image']['tmp_name']; $image_n = $_post['image_n']; $image_description = $_post['image_description'];  $allowed_ext = array('jpg', 'jpeg', 'png', 'gif', 'rar', 'pdf'); //$image_ext = strtolower(end(explode('.', $image_name)));  $image_ext = pathinfo($image_name, pathinfo_extension);  $album_id = $_session['varname'];  $errors = array();  if (empty($image_name) || empty($album_id) || empty($image_n) ||         empty($image_description)) {      $errors[] = 'something missing'; } else {  if (strlen($album_name) > 55 || strlen($album_description) > 255) {         $errors[] = 'one or more fields contains many characters';     }  if (in_array($image_ext, $allowed_ext) === false) {     $errors[] = 'file type not allowed';  }  //if ($image_size > 2097152) { //  $errors[] = 'maximum file size 2mb'; //}  if (album_check($album_id) === false) {     $errors[] = 'couldn\'t upload album'; }  }  if (!empty($errors)) {     foreach ($errors $error) {         echo $error, '<br />';     }  } else {     $byte = formatsizeunits($bytes);     upload_image($image_temp, $image_ext, $album_id, $image_n, $image_description, $byte);     header('location: view_album.php?album_id='.$album_id);     exit(); } }  $albums = get_albums();  if (empty($albums)) { echo'<p>you don\'t have albums. <a href="create_album.php">create album</a></p>'; } else { ?>  <form action="" method="post" enctype="multipart/form-data"> <div class="choose">     <p>choose file:<br /><input type="file" name="image" /></p>     </div>         <div class="des">         <p>name*:<br /><input type="text" name="image_n" maxlength="55"/></p>         <p>description*:<br /><textarea name="image_description" rows="6" cols="35" maxlength="255"></textarea></p>       <p><input type="submit" value="upload" /></p>     </div> </form> <div class="foot"> <?php    }  include 'template/footer.php';   ?> </div> 

the form @ end of second page not load .. when delete first line @ main page $var_value = 7 ; form @ end load .. don't know problem or there other way set album value in main , pass included page

if there no problems found in $album_id, set $var_value, included file does:

$byte = formatsizeunits($bytes); upload_image($image_temp, $image_ext, $album_id, $image_n, $image_description, $byte); header('location: view_album.php?album_id='.$album_id); exit(); 

so never gets part displays form.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -