ballouta Posted June 16, 2008 Share Posted June 16, 2008 hi I have a complicated upload form, it is working but i have only one problem, I am not able to use the value of the get function in the $_POST['submit_id'] scope. the code is not short, but i will show u its beginig and its end. Note that when I echo the $user value before the $_POST['submit_id'] it working. the Begining: <?php //Include configuration file and function file //(default location is in the same directory) include('../CMS/global.inc.php'); include_once('config.php'); include_once('functions.php'); $user= $_GET['user']; //If contact is being sent: if($_POST['submit_id'] == 1){ //Check name entered //File Upload checks if($message == NULL && $FILE_UPLOAD == 1 && $_FILES['user_file']['name'] != NULL){ if($_FILES['user_file']['size'] > (($FILE_UPLOAD_MAX*1024)*1024)){ $message = 'File is over '.$FILE_UPLOAD_MAX.' MB in size.';} if($message == NULL && allowed_ext($FILE_UPLOADS_EXT,$_FILES['user_file']['name']) == false){$message = 'Invalid extension.';} // $new_filename = date("G_i_s_").$_FILES['user_file']['name']; $new_filename = $_FILES['user_file']['name']; $date = date("y-m-d"); $query=" INSERT INTO `DB`.`uploaded` ( `user` , `sentfile` , `date` , `received`) VALUES ('meno', '$new_filename', '$date', 'N')"; $query_result = mysql_query ($query, $dbh); } This is the end of th form: <?php } if($FILE_UPLOAD == 1){?> <tr> <td>File Upload </td> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><input name="user_file" type="file" id="user_file"> </td> </tr> <tr> <td><font color="#FF0000" size="2"> Please KEEP your .ask file name as if. Allowed Extension: <?php if($FILE_UPLOADS_EXT == 1){ echo 'All';}else{ foreach($FILE_UPLOADS_EXT as $ext){ echo '*'.$ext;}}?> </font></td> </tr> </table> </td> </tr> <tr> <td colspan="2"><div align="center"> <input type="submit" name="Submit" value="Send File"> <input name="submit_id" type="hidden" id="submit_id" value="1"> </div></td> </tr> <?php } ?> Why $user is not available in the first piece of code? How do I fix it please? Thanks Link to comment https://forums.phpfreaks.com/topic/110471-solved-unable-to-get-a-value/ Share on other sites More sharing options...
rhodesa Posted June 16, 2008 Share Posted June 16, 2008 Post the code the <FORM> tag Link to comment https://forums.phpfreaks.com/topic/110471-solved-unable-to-get-a-value/#findComment-566750 Share on other sites More sharing options...
ballouta Posted June 16, 2008 Author Share Posted June 16, 2008 Here's the form in the same file: upload.php it is very very complicated for me. <?php } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="contact" id="contact" style="display:inline;"> <table width="100%" border="0" align="left" cellpadding="5" cellspacing="0"> <?php if($IMAGE_VERIFICATION == 1){?> <tr> <td>Verification code:</td> <td> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td><?php $referenceid = md5(mktime()*rand()); //Generate the random string $chars = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k", "K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v", "V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9"); $length = 8; $textstr = ""; for ($i=0; $i<$length; $i++) { $textstr .= $chars[rand(0, count($chars)-1)]; } $new_string = RC4($textstr,$IMAGE_VER_CODE); $image_link = bin2hex($new_string); ?> <img src="sec_image.php?code=<?=$image_link;?>"> <input name="hid_code" type="hidden" id="hid_code" value="<?=$image_link;?>"><br/> <input name="confirm_image" type="text" id="confirm_image" value="<?php echo $_POST['confirm_image'];?>"></td> </tr> </table> </td> </tr> <?php } if($FILE_UPLOAD == 1){?> <tr> <td>File Upload </td> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><input name="user_file" type="file" id="user_file"> </td> </tr> <tr> <td><font color="#FF0000" size="2"> Please KEEP your .ask file name as if. Allowed Extension: <?php if($FILE_UPLOADS_EXT == 1){ echo 'All';}else{ foreach($FILE_UPLOADS_EXT as $ext){ echo '*'.$ext;}}?> </font></td> </tr> </table> </td> </tr> <tr> <td colspan="2"><div align="center"> <input type="submit" name="Submit" value="Send File"> <input name="submit_id" type="hidden" id="submit_id" value="1"> </div></td> </tr> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/110471-solved-unable-to-get-a-value/#findComment-566755 Share on other sites More sharing options...
rhodesa Posted June 16, 2008 Share Posted June 16, 2008 change action="<?php echo $_SERVER['PHP_SELF'];?>" to action="<?php echo $_SERVER['REQUEST_URI'];?>" Link to comment https://forums.phpfreaks.com/topic/110471-solved-unable-to-get-a-value/#findComment-566759 Share on other sites More sharing options...
ballouta Posted June 16, 2008 Author Share Posted June 16, 2008 You are Genius Thanks alot Link to comment https://forums.phpfreaks.com/topic/110471-solved-unable-to-get-a-value/#findComment-566779 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.