Re: A prepared statements question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jul 12, 2009 at 10:01 AM, Jason Carson <jason@xxxxxxxxxxxxxx> wrote:

> Hello everyone,
>
> I am having a problem getting my prepared statements working. Here is my
> setup...
>
>    index.php -> authenticate.php -> admin.php
>
> 1)index.php has a login form on it so when someone enters their username
> the form redirects to another page I call authenticate.php.
>
> 2)In the authenticate.php file I want to use prepared statements to
> interact with the MySQL database. I want to compare the username submitted
> from the form with the username in the database.
>
> 3)If the login username was legitimate then you are forwarded to admin.php
>
> Its step 2 I am having problems with. Here is what I have but I don't
> think it makes any sense and it doesn't work.
>
>
> $link = mysqli_connect($hostname, $dbusername, $password, $database);
> $stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE
> adminusers=?");

No Password ? I hope you are only using the statement for determining the
role of already logged in user.

> mysqli_stmt_bind_param($stmt, 's', $username);
> $result = mysqli_stmt_execute($stmt);
>
> $count=mysqli_num_rows($result);
>
> if($count==1){
> header("location:admin.php");
> } else {
> echo "Failure";
> }
>
> Any help is appreciated.
>

You forgot to mention the about the problem you are facing :), "I am having
problem" statement is not good enough.


>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Zareef Ahmed :: A PHP Developer in India ( Delhi )
Homepage :: http://www.zareef.net

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux