Code Monkey home page Code Monkey logo

learning-php's Introduction

XAMPP MySQL Form

A demonstration of a HTML form that submits data to a MySQL database running on XAMPP.

Contents:


Requirements

Linux:

  • Apache
  • MySQL Server
  • HTML5-compatible browser

Windows:

  • XAMPP, running:
    • Apache
    • MySQL Server
  • HTML5-compatible browser

Setup & Use

Prerequisites

Linux:

You'll need the packages for MySQL (most common client is MariaDB) and Apache (known on some platforms as httpd):

# Debian/Ubuntu and compatibles:
sudo apt install mysql-client apache2

# Arch and most other distros: (Substitue in your package manager instead)
sudo pacman -S mariadb apache

Start both servers:

# Debian/Ubuntu:
sudo systemctl start apache2
sudo systemctl start mysql

# Arch and others:
sudo systemctl start httpd
sudo systemctl start mariadb

Set up MySQL:

sudo mysql -u root # root privileges are needed to create a new database and users.
CREATE DATABASE learning;
USE learning;
CREATE TABLE student_details (id text, PRIMARY KEY (id(6)), name text, surname text, cool text);

-- Password is "1337":
CREATE USER apache IDENTIFIED BY PASSWORD "*C6F8F27F2F530B7B270D641A3604424B9B404D43";
GRANT SELECT, INSERT, UPDATE ON *.* to apache;

EXIT;

Windows:

Navigate to localhost:80/phpmyadmin.

Create a new database:
  • DatabasesDatabase name → "learning" → Create
  • Create tableName: → "student_details" → Number of columns: → 4
  • Insert the following in to the console at the bottom:
CREATE TABLE student_details (id text, PRIMARY KEY (id(6)), name text, surname text, cool text);
  • Ctrl+Enter
Create a new user:
  • Go to phpMyAdmin homepage
  • User accountsNewAdd user account:
Field Value
User name: apache
Host name: %
Password: 1337
Authentication plugin: Native MySQL Authentication
  • Global privelegesData → enable SELECT, INSERT, and UPDATE
  • SSLREQUIRE NONE
  • Go

Download

git clone https://github.com/toydotgame/learning-php.git; cd learning-php/

Install

Linux:

# Debian/Ubuntu and compatibles:
sudo cp -rf . /var/www/html/

# Arch and other httpd versions of Apache:
sudo cp -rf . /srv/http/

Then open your browser to localhost:80 to see the form page.

Windows:

In XAMPP's Control Panel, go to the Apache Module → ActionsConfigApache (httpd.conf), and find DocumentRoot, set it to the directory that this repository was cloned to. i.e:

DocumentRoot "C:/Users/User/Documents/learning-php"

Then, navigate to localhost:80 in your browser to see the form page.


Database Administration

Linux:

Login to MySQL: (password is "1337")

mysql -u apache -p learning

Show all data in the database and/or select a single entry via <student number>:

SELECT * FROM student_details;
SELECT * FROM student_details WHERE id LIKE "<student number>";

Windows:

Navigate to localhost:80/phpmyadmin and find the student_details table (under the learning database) in the left column. Click on that and view database entries on the right.

learning-php's People

Contributors

toydotgame avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.