Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages