/    Sign up×
Community /Pin to ProfileBookmark

Create a $_SESSION from input field in form…

Hello,

I’m trying to create a $_SESSION called ‘cname’ from the data inserted into this form.

Here’s my PHP to slightly validate it:

[code=php]
if (!isset($_POST[‘company_name’][3])) {
$companynameclass = “errortext”;
$cn = FALSE;
} else {
$cn = escape_data(strip_tags(stripslashes(trim($_POST[‘company_name’]))));
$companynameclass = FALSE;
}
[/code]

and the HTML input field

[code=html]
<div class=”required”>
<label for=”company_name” class=”<?php if (!empty($companynameclass)) { echo $companynameclass; } ?>”>Company Name:</label>
<input type=”text” name=”company_name” id=”company_name” class=”inputText” size=”10″ maxlength=”60″ value=”<?=$_POST[company_name] ?>”/>
<?php if (!empty($companynameclass)) { echo ‘<p class=”errortext2″>Please enter a company name.</p>’; }?>
</div>
[/code]

Can someone show me how to create the SESSION in the first place then update it if the value changes??

Thanks a million!

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@invisionauthorNov 07.2007 — [b]^^ Please Ignore The Above ^^[/b]
×

Success!

Help @invision 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.7,
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,
)...