VikasSharma Posted January 14, 2017 Share Posted January 14, 2017 please tell me about the error in this code and help me to resolve the error <html> <head> <title> using one page to accept and process data. </title> </head> <body> <h1> using one page to accept and process data. </h1> <?php if (isset($_REQUEST ["flavour"]) ) { echo "your favourite flavour is". $_REQUEST["flavour"] ; } ?> <?php if (isset($_REQUEST["name"] ) ) { echo "your name is" . $_REQUEST["name"]; } else { ?> <form method = "post" action = "phpone.php"> what is your favourite ice cream flavor? <input name = "flavor" type = "text"> <br> <br> what is your name? <input type = "text" name = "name" > <br> <br> <input type = submit value = submit > </form> <?php } ?> </body> </html> phpone1.php Quote Link to comment https://forums.phpfreaks.com/topic/302931-putting-all-the-data-in-one-page/ Share on other sites More sharing options...
Barand Posted January 14, 2017 Share Posted January 14, 2017 Your code is mid-atlantic <input name = "flavor" type = "text"> if (isset($_REQUEST ["flavour]) ) Quote Link to comment https://forums.phpfreaks.com/topic/302931-putting-all-the-data-in-one-page/#findComment-1541380 Share on other sites More sharing options...
Destramic Posted January 14, 2017 Share Posted January 14, 2017 (edited) please use the code tags so it makes things easier for people to read. i can see an error here: if (isset($_REQUEST ["flavour"]) ) { //<input name = "flavor" type = "text"> which should be if (isset($_REQUEST["flavour"])) { //<input name = "flavour" type = "text"> why don't you try something like this? <html> <head> <title> using one page to accept and process data. </title> </head> <body> <h1> using one page to accept and process data. </h1> <?php if ($_SERVER['REQUEST_METHOD'] === 'POST') { print_r($_POST); } else { ?> <form method="post"> what is your favourite ice cream flavor? <input name = "flavor" type = "text"> <br> <br> what is your name? <input type = "text" name = "name" > <br> <br> <input type = submit value = submit > </form> <?php } ?> </body> </html> Edited January 14, 2017 by Destramic Quote Link to comment https://forums.phpfreaks.com/topic/302931-putting-all-the-data-in-one-page/#findComment-1541381 Share on other sites More sharing options...
benanamen Posted January 14, 2017 Share Posted January 14, 2017 You are expecting a POST array so look for a POST array. Do not use REQUEST. That includes POST, GET and COOKIES. if (isset($_POST ["flavour]) ) Quote Link to comment https://forums.phpfreaks.com/topic/302931-putting-all-the-data-in-one-page/#findComment-1541385 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.