MathieuF Posted February 11, 2016 Share Posted February 11, 2016 (edited) So i'm doing the PHP tutorial and for some reason $_POST or $_REQUEST are not getting filled up So the form is this D:\PHPStormProjects\W3schoolTutorial\Forms\PhpFormPt1.php <html> <body> <form action="welcome.php" method="post"> Name: <input type="text" name="name" id="name"><br> E-mail: <input type="text" name="email"><br> <input type="submit" name="submit"> </form> </body> </html> AND the php is this I added some things to test(used quote as somehow code made it go blank) D:\PHPStormProjects\W3schoolTutorial\Forms\Welcome.php<html><body>Welcome <?php echo ($_POST['name']);print "CONTENT_TYPE: " . $_SERVER['CONTENT_TYPE'] . "<BR />";print "DATA: <pre>";var_dump($data);var_dump($_POST);print "</pre>";?><br>Your email address is: <?php echo $_POST['email']; ?></body></html> Welcome Notice: Undefined index: name in D:\PHPStormProjects\W3schoolTutorial\Forms\Welcome.php on line 4 Notice: Undefined index: CONTENT_TYPE in D:\PHPStormProjects\W3schoolTutorial\Forms\Welcome.php on line 6 CONTENT_TYPE: DATA:string(47) "name=name&email=email%40email.com&submit=Submit" array(0) { } Your email address is: Notice: Undefined index: email in D:\PHPStormProjects\W3schoolTutorial\Forms\Welcome.php on line 15 EDIT: Tested it with netbeans instead of PHPStorm and that lets it run fine (if someone knows what setting i could have done wrong in PHPStorm feel free to post down below as for now i'll keep using netbeans) EDIT2: think the problem is related to this http://stackoverflow.com/questions/35290133/phpstorm-post-always-empty-solved BUT i have no idea how or what he did to fix it Edited February 12, 2016 by MathieuF Link to comment Share on other sites More sharing options...
justsomeguy Posted February 11, 2016 Share Posted February 11, 2016 Where does that $data variable get defined? Link to comment Share on other sites More sharing options...
Ingolme Posted February 12, 2016 Share Posted February 12, 2016 If you did not arrive to the page by submitting the form, then $_POST['data'] will be undefined and PHP will show an error message. Link to comment Share on other sites More sharing options...
Petrucho Posted February 12, 2016 Share Posted February 12, 2016 It has to be something with your php version or configuration. I have just tried the code on my server. output: Welcome petruchoCONTENT_TYPE: application/x-www-form-urlencodedDATA:NULLarray(3) {["name"]=>string(8) "petrucho"["email"]=>string(18) "petrucho@gmail.com"["submit"]=>string(6) "Submit"}Your email address is: petrucho@gmail.com Try the function phpinfo(); 1 Link to comment Share on other sites More sharing options...
MathieuF Posted February 12, 2016 Author Share Posted February 12, 2016 (edited) To be clear to all of you it works completely with neatbeans (see edit) so it has something to do with MyPhpStorm configuration i'll try to figure out what i could be when i've more time but for now i'll continue in netbeans If you did not arrive to the page by submitting the form, then $_POST['data'] will be undefined and PHP will show an error message. I arrived in the page but var_dump($_POST) clearly shows that it is empty tho Where does that $data variable get defined? Seems it didn't copy all my code too but $data is configured as $ data = file_ get _contents(' php:/ /input'); i added extra spaces as this code seems to dissapear Edited February 12, 2016 by MathieuF Link to comment Share on other sites More sharing options...
justsomeguy Posted February 12, 2016 Share Posted February 12, 2016 You may have PHPStorm set up to run PHP scripts using the command line: https://www.jetbrains.com/phpstorm/help/run-debug-configuration-php-script.html Doing that will not populate $_POST, $_SESSION, $_COOKIE, $_GET, or other things that require a web server. It sounds like there is a built-in web server you can use though: https://www.jetbrains.com/phpstorm/help/run-debug-configuration-php-built-in-web-server.html Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now