开发者

PHP: Use post to retrieve 'user inputted data' in pseudocode & is Array("value) => $bool allowed?

Trying to write some PHP pseudocode for a recruitmentposter to hang at my university.

The idea is to make readers walk through a list of requirements in their head and go to the QR code if they think they fit the description.

Unfortunately I have virtually no experience @ PHP and therefore am having some difficulty figuring out the following three things:

  1. Do I need to use $post(value of ...) to 'retrieve' their personal information or is sim开发者_Go百科ply stating the variable/bool enough?

  2. Can I use an array like I did in $skills? Basically I want readers to imagine the following: skilltype | myskill

  3. Is assigning a bool value for the array entries of $interests correct like this? Here I'd want readers to think: Interest | personalboolvalue

It would be no surprise to me if this is complete and utter nonsense but it's what I produced after about an hour and a half of sleep-deprived searching. I'd be ever grateful if anyone could shed some light on the matter.

<?php

$skills = array ("PHP" => $level, "HTML5" => $level, "CSS3" => $level, "SQL" => $level);

$interests = array ("iOS" => $bool, "start_up" => $bool, "money" => $bool);

if ($skill[0, 1, 2, 3] == "expert") {
    if ($interests[0, 1] == TRUE && $interests[2] == FALSE) {
        if ($interested && $entrepreneur && $concrete_exp && $willing_to_commit) {
            echo "Please go to /images/qrcode.png";
        }
    }
}

?>


Full working solution with nice HTML:

<?php
// form submission haldling
if (isset($_POST["submit"])) {
    if (isset($_POST["skills"]) &&
            isset($_POST["interests"]) &&
            $_POST["skills"] == array("PHP", "HTML", "CSS3", "SQL") &&
            $_POST["interests"] == array("iOS", "start_up")) {
        header("location: /images/qrcode.png");
    } else {
        echo "We are not interested by your profile.";
    }
}

$skills = array("PHP", "HTML", "CSS3", "SQL", "World of Warcraft");
$interests = array("iOS", "start_up", "money");
?>

<form name="poll" action="" method="POST">
    <fieldset>
        <legend><h2>Skills</h2></legend>
        <?php foreach ($skills as $skill) : ?>
            <div>
                <input type="checkbox" name="skills[]" id="<?php echo $skill ?>" value="<?php echo $skill ?>">
                <label for="<?php echo $skill ?>"><?php echo $skill ?></label>
            </div>
        <?php endforeach; ?>
    </fieldset>
    <fieldset>
        <legend><h2>Interests</h2></legend>
        <?php foreach ($interests as $interest) : ?>
            <div>
                <input type="checkbox" name="interests[]" id="<?php echo $interest ?>" value="<?php echo $interest ?>">
                <label for="<?php echo $interest ?>"><?php echo $interest ?></label>
            </div>
        <?php endforeach; ?>
    </fieldset>
    <input type="submit" name="submit"/>
</form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜