TAILIEUCHUNG - Lecture Introduction to web engineering - Lec 28: Database connectivity in PHP

After studying this chapter you will be able to understand: Writing regular expression in PHP, validating user’s input, string functions, creating database in MySQL using WAMP, connecting PHP with MySQL, inserting data in database, connections: user registration. | Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1 Writing regular expression in PHP Validating user’s input String functions Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan. 2 2 Department of Computer Science, CIIT Islamabad. Creating database in MySQL using WAMP Connecting PHP with MySQL Inserting data in database CONNECTIONS: user registration Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 3 3 Department of Computer Science, CIIT Islamabad. Go to home page of WAMP server Select PHP myadmin Login to MySql Enter database name and click create database button Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 4 Creating a table in a database: Select database from the list of databases Enter table name and number of columns Enter name, data-type and other required properties for columns Click create table button Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 5 mysql_connect(“hostname” ,”username”, ”password”) mysql_connect(“localhost”,”root”,””) mysql_select_db(“database name”) mysql_select_db(“testdatabase”) Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 6 Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 7 Connect with server Host name username Empty password Error message Select database Database name Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 8 Create form to receive input from user On action page Retrieve user’s input Validate user’s input (optional) Establish connection with database Write insert command Execute command Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 9 Insert SQL command: INSERT INTO `table_name` (list of columns) VALUES (list of values) INSERT INTO users (‘user_Name’,’user_Email’,’user_Password’) VALUES (‘$name’,’$email’,’$password’) mysql_query(query to execute) Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 10 post for later use name email password Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 11 User’s input is retrieved Database connection Insert command Command is executed Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 12 Header function location message Close warnings Message is displayed Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 13 message Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 14 Create database Database name: connections Table name: users Table columns: user_Id int 4 User_Name text 25 User_Email varchar 35 User_Password varchar 20 User_Picture varchar 50 Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 15 name email password post Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 16 Connection to the server Database selection Database name Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 17 User’s input is retrieved Database connection Name validation Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 18 Email validation Insert command Command is executed Creating database in MySQL using WAMP Connecting PHP with MySQL Inserting data in database CONNECTIONS: user registration Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 19 Chapter 30, “Beginning PHP and MySQL” by W. Jason Gilmore, Apress publisher, 4th edition; 2010, ISBN-13 (electronic): 978-1-4302-3115-8. Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 20

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.