0

I'm a student new to MySQL working on a website containing information about elementary school students. Our instructor has required that the website support multiple administrator logins. I have created the table containing the ADMIN data, but I am a bit confused as to how to retrieve these values. I believe I am to use a mysql_query, but I am not exactly sure how to structure this statement.

Here is what I have so far. Thanks in advance:

--Table: ADMINS
create table ADMINS (
U_ID    integer     primary key AUTO_INCREMENT,
U_NAME  char(25)    not null,
U_PSSWD char(25)    not null
);

--Insert ADMINS data
insert into ADMINS values('t_wallace', 'maplesyrup');
insert into ADMINS values('t_hammett', 'pancakes');
insert into ADMINS values('q_malaki', 'bacon');

Here is my PHP so far:

<html><body>
<?php

<input type="text" name="u_name"/>
<br/>              
<input type="password" name="pss_word"/>
<br/>
<input type="submit" value="Submit" />
</form>

$con = mysql_query --Here is where I am confused as to retrieve the U-Name & U_PSSWD values.

$login = mysql_connect() -- I assume once I receive assistance with my $con variable, I will be able to figure this out.
Veronica
  • 23
  • 4
  • 2
    since you're a student, you should start learning things right: **don't** use the `mysql` functions, they are deprecated and in PHP7 removed. use [mysqli](http://php.net/manual/en/book.mysqli.php) or [PDO](http://php.net/manual/en/book.pdo.php) instead. the links provide you with all information you need. **don't ever** store passwords as plain text even once, use `password_hash()` and `password_verify()` instead. – Franz Gleichmann Nov 22 '16 at 19:40
  • Wow. Well, unfortunately our teacher has required that we use the statements he has provided. No need to be nasty. I just need a little assistance.@FranzGleichmann – Veronica Nov 22 '16 at 19:44
  • 2
    I don't think he was being nasty - just that comments are limited on length. He is right though. – Jay Blanchard Nov 22 '16 at 19:45
  • This is a basic level 1 course. We have not been provided with too many advance statements. This is a simple starter project. – Veronica Nov 22 '16 at 19:45
  • 3
    If teachers and professors are not talking about security from day one, they're doing it wrong. Challenge them. They're teaching sloppy and dangerous coding practices which students will have to unlearn later. – Jay Blanchard Nov 22 '16 at 19:46
  • 2
    i wasn't trying to be nasty, just helping you to learn the right way from the beginning. it's *never* too early to learn about best practices - lessions about simple data retreival basics should be done without password-columns, and without outdated functions that don't even exist in current software versions. you should tell your teacher that. – Franz Gleichmann Nov 22 '16 at 19:46
  • @FranzGleichmann I do understand what you are saying. There have been many times where we as students have challenged him, and he seems indifferent. These forums have provided me with a better learning experience than the classroom. – Veronica Nov 22 '16 at 19:48
  • @TiffanyIwinyoulose well, then i hope you stay here and keep on learning. but if he's indifferent, i bet he doesn't in any way validate his inputs. not that i would suggest actually doing anything like this, but maybe meeting good ol' [bobby tables](http://bobby-tables.com/) could induce a re-thinking process. – Franz Gleichmann Nov 22 '16 at 19:51
  • Ok so I have changed mysql_connect() to mysqli_connect(). Can anyone help me with how to set up my query? – Veronica Nov 22 '16 at 19:57

1 Answers1

-1

You should read the documentation for Php. It describes in detail how to use each Php function. For example: http://php.net/manual/en/function.mysqli-connect.php

Nadir Latif
  • 3,690
  • 1
  • 15
  • 24