Page 1 of 1

online registration system that post results on same page

Posted: Mon Dec 29, 2008 11:45 am
by tinoda
how can this be done without using databases but implementing html tables where if a user clicks register their input such as FIRSTNAME, etc gets posted immediately and permanently to an html table cell, all happening on the same page. I have managed to come up with a script below. I can successfully post the input results to the table but if i refresh the browser everything resets. how can i do it in such a way that even if a user refreshes the browser the results stay permanently in the table cell.

Code: Select all

<html>
<body><form action=" " method="POST">
Name: <input type="text" name="name" />
Age: <input type="text" name="age"  />
<input type="submit" name="submit"/>
</form>
 
<?php if($_POST['submit']) {
 
$name=$_POST['name'];
$age=$_POST['age'];
 
 echo " <table border='1'>
<tr>
<td>
Welcome
</td>
<td> 
$name 
</td>
</tr>
<tr>
<td>
You are
 </td>
<td>
 $age years old.
</td>
</tr>
</table>
</body>
</html>";
exit;
}
?>
 
pliz help am so desperate for this. i hv also tries using session cookies but it doesnt seem to work.

Re: online registration system that post results on same page

Posted: Mon Dec 29, 2008 1:07 pm
by califdon
A plain HTML page is inherently a one-shot deal--browser requests the page, server sends the page, process complete.

When you refresh the browser, it's going to just do the same thing again. It makes no difference what somebody may have entered in a form.

If you want to retain data while the browser remains on that page, you have to use Javascript to do it. If you want to retain data during repeated requests to the server, you have to do it with a PHP script that sets and reads $_SESSION variables or uses a database or file.

Re: online registration system that post results on same page

Posted: Mon Dec 29, 2008 1:13 pm
by tinoda
thanks Jack of Zircons, have been battling with php sessions the whole day i even hit my head against the wall but aint seem to progress. i also managed to set a php session but i just dont know where am going wrong. anywayz thanks for your suggestion. if u think u can help me again i will appreciate it.

Re: online registration system that post results on same page

Posted: Mon Dec 29, 2008 5:10 pm
by califdon
Just what is it that you want to do? You said you don't want to save the registration in a database, so it's not really a registration issue--you have no way to check a returning visitor. Is this just an exercise in PHP scripting, or do you have some purpose in asking for the information? If you just want to pass data from one page to another, you can set a $_SESSION variable (after using session_start(), of course) and check it in subsequent scripts during the same session, but of course those variables disappear when the time expires. If you want to pass it to a script, you could use PHP to populate a form field or, as I think you mentioned, an HTML table when you return a new page. But I'm unclear on what you want to do.

Your comment
permanently to an html table cell
doesn't mean anything, since HTML tables contain only what you put into them, they are certainly not permanent, except what you write into the script.

Re: online registration system that post results on same page

Posted: Mon Dec 29, 2008 9:48 pm
by omniuni
I am somewhat confused as well.

Even beyond making the table cell take on a value (in javascript, try using elementID.innerhtml='' ) how do you plan to use this? If you're looking for a simple way of storing data that is not a database, you could just write it into an array an dump it into a file using file_put_contents() and serialize(). That's a nice approach for simple stuff because then you can just reverse it to get the array back, and arrays can be sorted and looped through pretty easily.

Also, you could always link to what you're working on if you think it would help us better understand what you're doing.