Database Connectivity in PHP

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

pptx20 trang | Chia sẻ: dntpro1256 | Lượt xem: 804 | Lượt tải: 0download
Bạn đang xem nội dung tài liệu Database Connectivity in PHP, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
Database Connectivity in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.1Summary of the previous lectureWriting regular expression in PHPValidating user’s inputString functionsBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.2OutlineCreating database in MySQL using WAMPConnecting PHP with MySQLInserting data in databaseCONNECTIONS: user registration Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.31. Creating database in MySQL using WAMPGo to home page of WAMP serverSelect PHP myadminLogin to MySqlEnter database name and click create database buttonBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.41. Creating database in MySQL using WAMPCreating a table in a database:Select database from the list of databasesEnter table name and number of columnsEnter name, data-type and other required properties for columnsClick create table buttonBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.52. Connecting PHP with MySQLmysql_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.62. Connecting PHP with MySQLBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.7Connect with serverHost nameusernameEmpty passwordError messageSelect databaseDatabase name3. Inserting data in databaseBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.8Create form to receive input from userOn action pageRetrieve user’s inputValidate user’s input (optional)Establish connection with databaseWrite insert commandExecute command3. Inserting data in databaseBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.9Insert 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)3. Inserting data in databaseBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.10postreg_action.phpfor later usenameemailpassword3. Inserting data in databaseBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.11User’s input is retrievedDatabase connectionInsert commandCommand is executed3. Inserting data in databaseBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.12Header functionlocationmessageClose warningsMessage is displayed3. Inserting data in databaseBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.13message4. CONNECTIONS: user registrationBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.14Create databaseDatabase name: connectionsTable name: usersTable columns: user_Id int 4User_Name text 25User_Email varchar 35User_Password varchar 20User_Picture varchar 50 4. CONNECTIONS: user registrationBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.15nameemailpasswordpost4. CONNECTIONS: user registrationBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.16Connection to the serverDatabase selectionDatabase name4. CONNECTIONS: user registrationBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.17User’s input is retrievedDatabase connectionName validation4. CONNECTIONS: user registrationBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.18Email validationInsert commandCommand is executedSummaryCreating database in MySQL using WAMPConnecting PHP with MySQLInserting data in databaseCONNECTIONS: user registrationBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.19References 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

Các file đính kèm theo tài liệu này:

  • pptxlec28_database_connectivity_in_php_6498_2026976.pptx
Tài liệu liên quan