filter_var php question
I am making a quick little email开发者_StackOverflow社区 script for a contact form and these variable aren't being set($firstName
and $lastName
).
$firstName = filter_var($_POST['firstName'], FILTER_SANITIZE_STRING);
$lastName = filter_var($_POST['lastName'], FILTER_SANITIZE_STRING);
Note I am a beginner at php
You're a beginner? Well, hats off to you for using data validation from the get-go!
can you put this below those two lines and give us the output?
var_dump($firstName, $lastName, $_POST);
As you have mention that you are beginner at php, I think you have not set form method. By default form method is GET and you are trying to fetch value using POST method. So either you change your form method to POST or set variable as below :
$firstName = filter_var($_GET['firstName'], FILTER_SANITIZE_STRING); $lastName = filter_var($_GET['lastName'], FILTER_SANITIZE_STRING);
精彩评论