Storing the last input text whilst using the POST method with PHP -
the idea:
i have been trying create one-way chat system based on predictions user, using pre-set automatic responses through server side.
the problem:
what have far works great, although problem have can't store last user inputted message locally chat flow in messages without using lots of _get's.
with current code:
if (isset($_post['test'])) { $test = htmlentities($_post['test']); echo "<span class='you'>".$name."</span>: ".$test; if (preg_match('~\b(?:about)\b~', $test)) { echo '<br />'.$about; } else if (preg_match('~\b(?:projects?|works?)\b~i', $test)) { echo '<br />'.$projects; } else if (preg_match('~\b(?:contact|email|inquiry)\b~', $test)) { echo '<br />'.$contact; } else { echo "<br />error!"; } } for example, if user types projects input, $projects echo's correctly, after if user types about, $about show, previous projects message disappears.
what have tried:
- i've tried put each
ifin ownisset. - thought loop makes new input after every message, although believe not efficient use of php, need find more minimal way.
you use ajax old messages won't disappear on submit.
have <ul> chat messages. when user posts, create <li> message , 1 answer, , keep adding them...
Comments
Post a Comment