/    Sign up×
Community /Pin to ProfileBookmark

no emptying of fields?

here’s my simplified filename.php file

[QUOTE]

<html>
<body>
<form action=”filename.php” method=”post”>
Name: <input type=”text” name=”name” />
Age: <input type=”text” name=”age” />
<input type=”submit” />
</form>
<textarea cols=”50″ rows=”5″>
Welcome <?php echo $_POST[“name”]; ?>.<br />
You are <?php echo $_
POST[“age”] ; ?> years old.
</textarea>
</body>
</html>

[/QUOTE]

is there a way not to empty the fields
when i post (or a better method) the form to itself?
all fields are being cleared after submission..

and is a way to have the textarea empty at first
and write only after the page is resubmitted?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@scragarNov 04.2008 — [code=php]
Name: <input type="text" name="name" value="<?php echo $_POST["name"]; ?>" />
Age: <input type="text" name="age" value="<?php echo $_POST["age"]; ?>" />
[/code]
Copy linkTweet thisAlerts:
@andsoiwasauthorNov 05.2008 — i have already though of that..

is any better solution because my fields would have a default value at start..
[code=php]Name: <input type="text" name="name" value="<?php echo $_POST["name"]; ?>" />
Age: <input type="text" name="age" value="<?php echo $_POST["age"]; ?>" />[/code]

it should look like this before submission..
[code=html]Name: <input type="text" name="name" value="john" />
Age: <input type="text" name="age" value="20" />[/code]
Copy linkTweet thisAlerts:
@scragarNov 05.2008 — [code=php]<?php echo isset($_POST["name"])?$_POST["name"]:'john'; ?>[/code]
×

Success!

Help @andsoiwas spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...