Updating Session variable at a single click and showing result

0 Rishiraj A · December 20, 2014
My code is in here:

http://pastebin.com/W7nEtyS0

What I want to do is this,
When I click 'Submit' the $_SESSION['index'] variable gets updated, but at the same time I want the $text data to change
 since $paragraph[$_SESSION['index']] is updated now. This does not get reflect in my code. :(

I need to click 'Submit' twice to see the new data at '$text' variable

Post a Reply

Replies

Oldest  Newest  Rating
0 Aakash Ahmed · December 23, 2014
Assume form method is post and this is the submit button:
<button type="submit" name="submit_name" value="submit">Submit</button>

Then you will wrote something like this:
<?php
if( isset($_POST['submit_name'] ){
$_SESSION['index'] = "bla bla...";

// bunch of other code you want goes here
}
?>
  • 1

PHP

107,288 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators