Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7979375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:45:40+00:00 2026-06-04T09:45:40+00:00

I am learning some myqli and would like to make a simple check. Basically,

  • 0

I am learning some myqli and would like to make a simple check.

Basically, A user will enter their email addess then submit a form, if the email address is already contained in a certain mysql table, then the script must stop with an error.

This is my example:

$userEmail = sanitize($_POST['specials']);          
// Check to see if email already exists, if not proceed
if ($stmt = $link->prepare("SELECT email FROM specials WHERE email=$userEmail"))
{
    $specialsErrorFocus = 'autofocus="autofocus"';
    $specialsInfo = 'This email address: $userEmail, is already in our database.';
    include "$docRoot/html/shop/home.html.php";
    exit();
}

This code does not do as I have intended it to as described.

Could someone please explain where I am going wrong with this, or possibly offer a better solution for this task.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:45:41+00:00Added an answer on June 4, 2026 at 9:45 am

    You need to execute the query first, as simply preparing the statement is not sufficient. See the documentation as it is a multi stage process.

    First, you prepare the statement:

    $stmt = $link->prepare("SELECT `email` FROM `specials` WHERE `email` = ?")
    if (!$stmt) {
       echo $link->errno . " : " . $link->error;
    }
    

    Next, bind the parameters:

    if (!$stmt->bind_param("s", $userEmail)) {
        echo $stmt->errno . " : " . $stmt->error;
    }
    

    Finally, execute the query:

    if (!$stmt->execute()) {
        echo $stmt->errno . " : " . $stmt->error;
    }
    

    Get the results:

    $stmt->store_result();
    
    if ($stmt->num_rows) {
    
       # Email exists
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm interested in learning some python, and thought Pylons would be a good starting
Trying to learning some more PHP. Here is what I'm after. Essentially, I would
I just started learning some ruby, and I want to do something like this:
I vaguely remember learning about some sort of built-in function that would do the
I have been learning some Haskell and writing very simple programs. I want to
I am learning some COM code and the following code puzzled me. STDMETHODIMP _(ULONG)
I'm a beginner learning some assembly, when preserving the ESP register before a function
There is something I can't digest. I'm learning some assembler and right now I'm
Are there any PIC microcontroller programmers here? I'm learning some PIC microcontroller programming using
i have done some learning on struts based on one project that i got.Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.