MySQL

PHP Mysqli Database Connectivity

Mysqli PHP Connectivity

How to connect PHP through mysqli. Create a registration form with 4 four fields name,email id, mobile number and address. Fill all the fields click on save data submit button to save your data inside “users” table using mysqli prepared statements insert. To display all the values from “users” table click on disp data button it will display the values using mysqli prepared statements select.

Create Database and Table

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

//create a database

CREATE DATABASE`demo`;

USEdemo;

//create a table

CREATE TABLE`demo`.`users`(

`id`INTNOTNULLAUTO_INCREMENT PRIMARY KEY,

`name`CHAR(50)NOTNULL,

`email`VARCHAR(50)NOTNULL,

`mobile`BIGINT NOTNULL,

`address`TEXT NOTNULL,

UNIQUE(

`email`

)

)ENGINE=MYISAM;

PHP Script(PHP mysqli connection )

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

<?php

//mysqli connectivity

$connect=newmysqli("localhost","root","","demo")ordie("ERROR:could not connect to the database!!!!");