PHPMono
PHPMono

Reputation: 11

PHP Session won't save unique value

I want to save the name="" part of this button

<button type="submit" class="btn grey large" id="taxicompany" name="<? echo $rows['company']; ?>">select</button>

So when i do this

<?php echo "".$_SESSION['POSTDATA']['taxicompany'].''; ?>

it displays the value of name=""

But it won't display?

Upvotes: 0

Views: 55

Answers (2)

devpro
devpro

Reputation: 16117

Try this:

<form method="post">
<button type="submit" class="btn grey large" id="taxicompany" name="taxicompany" value="your company name">select</button>
</form>

// PHP code
if(isset($_POST['taxicompany']))
{
    $_SESSION['POSTDATA']['taxicompany'] = $_POST['taxicompany'];
    echo $_SESSION['POSTDATA']['taxicompany']; //your company name
}

Upvotes: 1

rchatburn
rchatburn

Reputation: 752

Why do you not give the button a value

<button type="submit" class="btn grey large" id="taxicompany" name="taxicompany" value="<? echo $rows['company']; ?>">select</button>

Then when you submit your form and reference $_POST['taxicompany'] you will have the value

http://www.w3schools.com/tags/att_button_value.asp

Upvotes: 4

Related Questions