I’m trying to take this and turn it into a function using a list figured I could loop through that list. Instead of writing the same line multiple times but each line having slight differences.
$FirstName = mysqli_real_escape_string($conn, $_POST['FirstName']);
$LastName = mysqli_real_escape_string($conn, $_POST['LastName']);
$Email = mysqli_real_escape_string($conn, $_POST['Email']);
$Username = mysqli_real_escape_string($conn, $_POST['Username']);
$Passphrase = mysqli_real_escape_string($conn, $_POST['Passphrase']);
$ConfirmEmail = mysqli_real_escape_string($conn, $_POST['ConfirmEmail']);
$ConfirmPassphrase = mysqli_real_escape_string($conn, $_POST['ConfirmPassphrase']);
Here is my list.
$FieldValues = array(‘FirstName’, ‘LastName’, ‘Email’, ‘Username’, ‘Passphrase’, ‘ConfirmEmail’, ‘ConfirmPassphrase’);
$vars = list($FirstName, $LastName, $Email, $Username, $Passphrase, $ConfirmEmail, $ConfirmPassphrase) = $FieldValues;
And this is my function which is currently not working.
function RetriveFieldValues() {
while ($vars = each($FieldValues)) {
$vars = mysqli_real_escape_string($conn, $_POST[$FieldValues]);
}
}