Issue
This Content is from Stack Overflow. Question asked by Delano van londen
I am making a WordPress plugin. I have to create a Name and email checker.
i have a form with POST method. In this form you fill your email and name
<form method="post">
<input type="text" name="yourname" placeholder="name" required>
<input type="text" name="mail" placeholder="email" required>
<input class="btnAdd" type="submit" value="Add">
</form>
Then i want to make a sql query to check if there is a user with the email that has been filled in. i console.log’d $EmailCheckResults from below here. and it gives this back:
SELECT user_email FROM users WHERE user_email = 0
global $wpdb;
$emailToCheck = $_POST['mail'];
$EmailCheckResults = $wpdb->prepare("SELECT user_email FROM users WHERE user_email = %d", $emailToCheck);
$CheckResults = $wpdb->get_var($EmailCheckResults);
any ideas why %d is 0? even if i fill in the email input
Solution
According documentation %d mean – digit placeholder. Use %s for strings.
This Question was asked in StackOverflow by Delano van londen and Answered by Slava Rozhnev It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.