Form to create

Ask about a PHP problem here.
Post Reply
Xenilbohl
Posts: 10
Joined: Fri May 06, 2011 7:38 pm

Form to create

Post by Xenilbohl »

Well what I want to do is when someone types something into a field it changes something else in say a text box.

For example I have a sentence and it begins " My name is 'X''

Then I have a field where they type in there name and either live or they click a button and it changes the sentence. How would I do this?

Thank you.
Image< my attempt at a logo ;)
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Form to create

Post by jacek »

just using $_POST['name'] you could do

[syntax=php]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<div>
<?php

if (isset($_POST['name'])){
echo "Your name is ", htmlentities($_POST['name']);
}

?>
<form action="" method="post">
<p>
<input type="text" name="name" />
<input type="submit" value="Update" />
</p>
</form>
</div>
</body>
</html>[/syntax]
Image
Xenilbohl
Posts: 10
Joined: Fri May 06, 2011 7:38 pm

Re: Form to create

Post by Xenilbohl »

Great! Thank you jacek
Image< my attempt at a logo ;)
User avatar
Kamal
Posts: 123
Joined: Fri May 06, 2011 10:45 am
Contact:

Re: Form to create

Post by Kamal »

To do it live, you must use javascript. PHP is not for client-side stuff.
Post Reply