linkcool Posted March 15, 2010 Share Posted March 15, 2010 Hi everybody, im linkcool, im new here and i have a little problem. I've been making some php for about 2 weeks now and i got a problem with a form and a $_POST. here is the upload.php file, it gets redirected into uploadverify.php <?php session_start(); if(!session_is_registered(username)) { session_register("wrongpage"); $_SESSION['wrongpage'] = "Sorry you are not logged in so you can't visit this page: Upload.php <br/>"; header("location:login.php"); } else{} echo '<table border="0"><tr><td width="500"> </td><td><a href="logout.php">Logout!</a></td></t></table><br/ >'; echo "All kind of files are supported <br/><br/>"; ?> <table> <form action="UploadVerify.php" method="post" enctype="multipart/form-data"> <tr> <label for="file"><td width="200">Filename:</td></label> <td><input type="file" name="file" id="file" /></td> </tr> <tr> <td>Description: (optionnal)</td><td><input type="text" name="description" /></td> </tr> <tr> <td> Album: </td> <td> <input type="text" name="something1" /> </td> </tr> <tr> <td></td><td><input type="submit" name="submit" value="Upload!" /></td> </tr> </form> </table> <?php echo 'New feature!:<br/>'; echo '<a href="view.php">View all YOUR uploaded images</a>' ?> It is a form where the user uploads a file and write something in the description textbox and something in the "something1" textbox(it was "album" before). So when the user click: upload!, it makes the uploadverify.php action. In there, the user can see the description as he writen it in the textbox, but the album dont show up. And they are both same input. I tryed the var_dump($_POST['something1']) and it does not return it as NULL, it returns as: string(0) "" . So does anyone know how to make the $_POST['something1'] have it's value? because it returns empty... And why the $_POST['description'] does not return empty? thank you, linkcool Quote Link to comment https://forums.phpfreaks.com/topic/195262-_post-is-empty/ Share on other sites More sharing options...
aleX_hill Posted March 15, 2010 Share Posted March 15, 2010 I cant help you out too much, but try calling print_r($_POST) from your UploadVerify.php This will dump out ALL the $_POST variables to make it easier to see what is set, and what each value holds. Quote Link to comment https://forums.phpfreaks.com/topic/195262-_post-is-empty/#findComment-1026167 Share on other sites More sharing options...
PFMaBiSmAd Posted March 15, 2010 Share Posted March 15, 2010 Your code in UploadVerify.php must be overwriting the value (we would need to see the code to be able to tell) or register_globals are on and you have a same name session or cookie variable that is overwriting the value. Your code is also using session_is_registered/session_register and session_start/$_SESSION variables at the same time. You should only be using session_start/$_SESSION variables both because you should not mix the two methods and because session_is_registered/session_register was depreciated nearly 8 years ago and will be completely removed in php6. You also need an exit; statement after your header redirect to prevent the remainder of the code on the page from executing. Your existing code does not protect anything. Quote Link to comment https://forums.phpfreaks.com/topic/195262-_post-is-empty/#findComment-1026238 Share on other sites More sharing options...
linkcool Posted March 15, 2010 Author Share Posted March 15, 2010 Your code in UploadVerify.php must be overwriting the value (we would need to see the code to be able to tell) or register_globals are on and you have a same name session or cookie variable that is overwriting the value. Your code is also using session_is_registered/session_register and session_start/$_SESSION variables at the same time. You should only be using session_start/$_SESSION variables both because you should not mix the two methods and because session_is_registered/session_register was depreciated nearly 8 years ago and will be completely removed in php6. You also need an exit; statement after your header redirect to prevent the remainder of the code on the page from executing. Your existing code does not protect anything. Woaw, i never tought about that but your first paragraph sayd it all, I accidently overwited the value, i writed: if($_POST['something1'] = "" ){ instead of if($_POST['something1'] == ""){ But what should i use instead of all that session stuff? and, are you sure the exit; statement will "play" if i redirect, and what it does?? Anyway, thank you very much. linkcool Quote Link to comment https://forums.phpfreaks.com/topic/195262-_post-is-empty/#findComment-1026308 Share on other sites More sharing options...
PFMaBiSmAd Posted March 15, 2010 Share Posted March 15, 2010 But what should i use instead of all that session stuff? isset($_SESSION['some_name']) would generally be used instead of session_is_registered() and setting a $_SESSION variable is the same as using session_register() and a regular variable name (since you are not referencing $wrongpage, your use of session_register() has no affect any way.) The specific code you have at that start of your file should be - <?php session_start(); if(!isset($_SESSION['username'])) { $_SESSION['wrongpage'] = "Sorry you are not logged in so you can't visit this page: Upload.php <br/>"; header("location:login.php"); exit; } echo ..... Quote Link to comment https://forums.phpfreaks.com/topic/195262-_post-is-empty/#findComment-1026313 Share on other sites More sharing options...
linkcool Posted March 15, 2010 Author Share Posted March 15, 2010 ok so i don't need to use session_is_registered(); and session_register(); anymore? (but anyway, i never really understanded what did session_register();...) Quote Link to comment https://forums.phpfreaks.com/topic/195262-_post-is-empty/#findComment-1026638 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.