how to make a form save what a user puts in

Status
Not open for further replies.

extacy

Member
Jan 6, 2011
106
2
so when someone puts there first name and last name into a form like so:
HTML:
<form>
First name: <input type="text" name="firstname" /><br />
Last name: <input type="text" name="lastname" />
</form>
how would i get it so save that information in a file for later use?
and how would i get it to show up in text in a different page like
oh hai first name last name

could some one help me please? thanks.
 

Dayron1234(2)

New Member
Jun 11, 2011
33
0
Your form is wrong try this:
PHP:
<form action="welcome.php" method="post">
First Name: <input type="text" name="fname" />
Last Name: <input type="text" name="lname" />
<input type="submit" />
</form>

If you want it to echo the results of that form its pretty simple.
PHP:
Welcome <?php echo $_POST["fname, lname"]; !
 

Rilax

Member
Jun 20, 2011
38
0
Code:
<html>
<head>
<script type="text/javascript">
function show_prompt()
{
var name=prompt("Please enter your name","Harry Potter");
if (name!=null && name!="")
  {
  document.write("Hello " + name + "! How are you today?");
  }
}
</script>
</head>
<body>

<input type="button" onclick="show_prompt()" value="Show prompt box" />

</body>
</html>

That's JavaScript with a prompt box.
 

Benden

maging ang maganda mamatay
Jun 4, 2010
2,281
1,480
It depends what you want done. If they are logging in code stuff in php. If you are using the echo put it in that file
 

extacy

Member
Jan 6, 2011
106
2
It depends what you want done. If they are logging in code stuff in php. If you are using the echo put it in that file
i want it to save what the user puts in, for example: when they type in the firstname box it will save it so i can use it on a different page
such as like you type it in then go to a different page and on that page it shows your firstname,
 

Rilax

Member
Jun 20, 2011
38
0
i want it to save what the user puts in, for example: when they type in the firstname box it will save it so i can use it on a different page
such as like you type it in then go to a different page and on that page it shows your firstname,

That's what the code I gave you does, they submit their name in a prompt box and it will say "Hello ____ _____" . But you could easily change the code to say "Welcome ____ ____". Here:

Code:
<html>
<head>
<script type="text/javascript">
function show_prompt()
{
var name=prompt("Please enter your name","Harry Potter");
if (name!=null && name!="")
  {
  document.write("Hello " + name + "! How are you today?");
  }
}
</script>
</head>
<body>

<input type="button" onclick="show_prompt()" value="Show prompt box" />

</body>
</html>
 
Status
Not open for further replies.

Users who are viewing this thread

Top