Dirty Bird Design
Dirty Bird Design

Reputation: 5533

Echo value based on what checkbox is checked

yesHave a simple thing here, but not that handy in PHP. Basically I have a form that will use jquery .ajax submit based on return from PHP script. This is pseudocode for example only

HTML

<form id="makepost" name="makepost" action="PHP/wronglish_submit.php" method="post">
    <input type="radio" name="logged" value="yes">Logged in
    <input type="radio" name="logged" value="no">Not logged in<br>
    <textarea></textarea>
    <input type="submit" name="sw" id="sw" value="Submit!">
</form>

PHP

<?php
    if($_POST['logged'] = "yes")  {
    echo "logged";
    die();
    } else {
    echo "not_logged";
    }
?>

I know that the first line is not right, can't figure out right way/most efficient way to go about this. I can handle the ajax on the return value, i just can't get it to return the right value.

thx

Upvotes: 0

Views: 189

Answers (2)

Mob
Mob

Reputation: 11098

Since it's a sensitive thing you're doing, use a strict comparison operator for that. === and not the assignment one =.

Upvotes: 1

Karoly Horvath
Karoly Horvath

Reputation: 96266

= is assignment.

if ($_POST['logged'] == "yes")

Upvotes: 5

Related Questions