Working with $_GET Variables
<?php
// GET
if(isset($_GET['day']) && isset($_GET['date']) && isset($_GET['year'])){
$day = $_GET['day'];
$date = $_GET['date'];
$year = $_GET['year'];
if(!empty($day) && !empty($date) && !empty($year)){
echo 'It is '.$day. ' '.$date.' '.$year;
} else {
echo 'Fill in all fields';
}
}
?>
<form action = "some2.php" method ="GET">
Day: <br><input type="text" name="day"><br>
Date: <br><input type="text" name="date"><br>
Year: <br><input type="text" name="year"><br><br>
<input type="submit" value="Submit">
</form>
Working with $_POST Variables
<?php
// POST
$match='pass123';
if(isset($_POST['password'])){
$password = $_POST['password'];
if(!empty($password)){
if($password == $match){
echo 'That is correct!';
} else {
echo 'That is incorrect!';
} else {
echo 'Please enter a password!';
}
}
}
?>
<form action = "some2.php" method ="POST">
Day: <br><input type="password" name="password"><br><br>
<input type="submit" value="Submit">
</form>
Using htmlentities for Security
$day = htmlentities($_GET['day']);
$date = htmlentities($_GET['date']);
$year = htmlentities($_GET['year']);
No comments:
Post a Comment