Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display user information onscreen using forms

Status
Not open for further replies.

DFORMS

Technical User
Jul 26, 2010
1
CA
Would anyone be able to explain to me how to keep user information, obtained using forms, displayed onscreen for future visits?

Here is my code :
Code:
<html>
	<head>
		<title>Exercice_7</title>
	</head>
	
	<script language="javascript">
	function getInfo(){
		
		var info_1 = document.forms[0].user_name.value;
		var info_2 = document.forms[0].user_email.value;
		var info_3 = document.skynet.user_color.value;
		
		document.getElementById('show_info_1').innerHTML = info_1;
		document.getElementById('show_info_2').innerHTML = info_2;
		document.bgColor = info_3;
		
	}
	</script>
	
	<body>
		<center>
		<form name="skynet">
		<table border="1">
		  <tr>
		  	 <td>
            <p>Prénom : </p>
		    </td>
	        <td>
			<input type="text" name="user_name" size="25px">
			</td>
		  </tr>
		  <tr>
		  	 <td>
            <p>Famille : </p>
		    </td>
	        <td>
			<input type="text" name="user_email" size="25px">
			</td>
		  </tr>
		  <tr>
		  	 <td>
            <p>Couleur Préférée : </p>
		    </td>
	        <td>
			<input type="text" name="user_color" size="25px">
			</td>
		  </tr>
			
          <tr>
          	<td>
          		&nbsp;
			</td>
			<td>
			<input type="button" value="Envoyer" onClick="getInfo(this.form)">
			<input type="reset" value="Annuler">
			</td>
		  </tr>

		  <tr>
		  	<td>
		  		<br /><br /><br /><br />
		  	</td>
			<td>
		  		<br /><br /><br /><br />
		  	</td>
		  <tr>
		  	<td>
		  		<p>Votre prénom : </p>
		  	</td>
		  	<td>
		  		<p id="show_info_1"></p>
				
		  	</td>
		  </tr>
		  <tr>
		  	<td>
		  		<p>Nom de famille : </p>
		  	</td>
		  	<td>
		  		<p id="show_info_2"></p>
				
		  	</td>
		  </tr>
		</table>
		</form>
		</center>

	</body>
</html>
I want to keep the information displayed and the background color for every visit. Can i achieve this without using php?

Thank you for support!
 
That depends on where you want to store the information:

If you want to store it on your server you need some type of storage mechanism be it a file or database, and since you would be storing this on the server you need a server side programming language to access, store and retrieve the data.

It doesn't have to be PHP, it could be ASP, or Coldfusion etc...

Alternatively if you want to store this on your visitor's computer, you could use cookies. Javascript is perfectly capable of accessing cookies stored in the client machine.
Cookies however can be erased, so any information stored in them should not be something irreplaceable.

You can start here to learn about setting and retrieving cookies.






----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top