/    Sign up×
Community /Pin to ProfileBookmark

Form data for Text Areas

I am making a PHP script in which I would like users to enter seperate entries on a new line in a text area, when I tested it out, the form data was just ignoring the new lines. Is there any way that I can accomplish this or do I need to have then use a character like a comma that I can use to split the string?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ChazzlMay 21.2008 — Explode the data using n as the seperator. Save that into an array and use as necessary.

[code=php]<?php

// filename.php
if( isset($_POST['userInformation']) ){
$aryData = explode("n", $_POST['userInformation']);
foreach( $aryData AS $key => $value ){
echo "$key => $value <br />";
}
}

?>[/code]


[code=html]<html>
<head>
<title>Form data for Text Areas</title>
<style type="text/css">
.container{
width:300px;
text-align:center;
border:1px solid #2F8B42;
background-color: #DDF6E2;
padding:5px;
margin:10px;
}
.container textarea{
border:1px solid #2F8B42;
}
</style>
</head>
<body>
<form action="filename.php" method="POST">
<div class="container">
<span style="font:bold 12pt sans-serif;">User Information:</span><br/>
<textarea name="userInformation" cols="25" rows="5"></textarea>
<input type="submit" value="Submit" style="float:right;" />
</div>
</form>
</body>
</html>[/code]
Copy linkTweet thisAlerts:
@natbobauthorMay 29.2008 — Thanks.
×

Success!

Help @natbob 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 6.1,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...