hiltyoutube.blogg.se

Getting user input php post
Getting user input php post












-> Now that we know the input in the form that holds the value for story isset

getting user input php post getting user input php post

-> Now to see if the form element that selects story is set using isset $output = null //-> Empty variable to hold display info from conditional $mountain = //-> Your story about the mountain $seaside = //-> Your story about the sea side set variables that have your story information. -> key/value pairs coming from your index.php page -> use var_dump($_POST) on story_get.php to check if the global $_POST array has -> (Provided the $_POST variable in fact has the values assigned to the global array) Use a conditional if() or switch statement to see if your $_POST is set and equal to one of your options for story. instead of I want to print 200+ words story relating to what User has chosen. " into "once upon a time there was Светослав exploring Kamchatka Peninsula.", etc. You'll want to use tokens, something like. :)Īssuming you want to use the form variables inside your stories. Of the options above, I would choose the text-file loading for sourcing your story text, if you're looking for something simple and easy to maintain. You could also have a separate file with all your stories assigned into variables (assuming you really just have a few, the performance impact of loading unused stories is minimal): $stories = This assumes you have a table called stories with fields story_id and story_text. $story_text = !empty($story) ? $story : 'No such story!' $stmt = $conn->prepare("SELECT * FROM stories WHERE story_id = ? LIMIT 1")

getting user input php post

If you want to load it from database: $conn = new mysqli($servername, $username, $password, $dbname) $story_text = is_file($path) ? file_get_contents($path) : 'No such story!' Then we load the text file containing the story: If you want to load it from a text file: // Here we sanitize the story ID to avoid getting hacked: You need to get that story from somewhere. I hope You understand what I'm trying to achieve, and be able to suggest easy solutions.

#Getting user input php post code#

My code is working fine, but instead of I want to print 200+ words story relating to what User has chosen. It's purely related to PHP POST / GET functions.












Getting user input php post