awx

← Blog

Walk-through · 13 November 2026

How to put your PHP and MySQL assignment online

You have a PHP page, a MySQL table and a bit of JavaScript, and a deadline. This walk-through puts all of it on an awx computer and gives you a link that keeps working for as long as the computer is on. Every screenshot is from a real computer.

What we are building

A class notes board. A form takes a note, PHP saves it in a MySQL table, and the page lists the latest notes. A few lines of JavaScript keep the Add button switched off until you type something. It is small on purpose: the same steps work for a bigger assignment. A live copy is running at classnotes.awanbox.com if you want to see where we end up. It is read-only, so nobody can change it.

https://myassignment.awanbox.com/
The Class notes page with a note typed into the text box and the Add button now active
The finished page. The Add button wakes up once there is something to send.

1. Make a computer

On the Computers page press New computer. The smallest size is enough for PHP and MySQL. Every size has a desktop with Chrome, which is handy if you want to test in the computer's own browser; the larger ones run it more smoothly. The box Keep it running until my credit runs out can wait until the end; we come back to it in step 8.

The New computer form with a name box, the sizes Small and Large with their price per hour, a disk, and a summary of disk, image and region
The New computer form. Small is chosen, at RM0.03 an hour. Press Create. It is usually ready in a few seconds.

2. Install PHP and MySQL

Open the computer and go to the Terminal tab. You are signed in as a normal user that can use sudo. PHP and MySQL are not installed, and one command adds them:

sudo apt update
sudo apt install -y php php-mysql mariadb-server

The install takes a minute or two. The package is MariaDB, the free drop-in version of MySQL: the commands and the PHP code are the same, and for an assignment you will not see a difference. Then start the database and check that everything answers:

sudo service mariadb start
php -v
mariadb --version
The Terminal tab showing php -v printing PHP 8.3, the database starting with OK, the MariaDB version, and a query listing three notes
The Terminal tab. This one also shows a query on the notes table from step 3.

3. Create the database

Type sudo mariadb to open the database prompt and paste this. It makes a database, a user that can only touch that database, and one table.

CREATE DATABASE school;
CREATE USER 'student'@'localhost' IDENTIFIED BY 'pick-your-own-password';
GRANT ALL ON school.* TO 'student'@'localhost';
USE school;
CREATE TABLE notes (
  id INT AUTO_INCREMENT PRIMARY KEY,
  text VARCHAR(200),
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

Choose your own password instead of the one in the example, and do not reuse a password you use anywhere else. The database only answers to programs on this computer, so the only thing that can reach it is your PHP code.

4. Add your code

Put your files in a folder, say /home/agent/site. You can upload them from your laptop in the Files tab, write them in the terminal, or ask the built-in agent in the chat to write a first version and then read what it wrote. This is the whole page for the board:

<?php
// Class notes board: PHP + MySQL (MariaDB) + a little JavaScript.
$db = new mysqli("localhost", "student", "change-me", "school");

if ($_SERVER["REQUEST_METHOD"] === "POST" && trim($_POST["text"] ?? "") !== "") {
    $stmt = $db->prepare("INSERT INTO notes (text) VALUES (?)");
    $text = substr(trim($_POST["text"]), 0, 200);
    $stmt->bind_param("s", $text);
    $stmt->execute();
    header("Location: /");
    exit;
}
$rows = $db->query("SELECT text, created_at FROM notes ORDER BY id DESC LIMIT 20");
?>
<!doctype html>
<title>Class notes</title>
<form method="post">
  <input name="text" id="t" maxlength="200" placeholder="Write a note for the class">
  <button id="b" disabled>Add</button>
</form>
<ul>
<?php while ($row = $rows->fetch_assoc()): ?>
  <li><?= htmlspecialchars($row["text"]) ?> <small><?= htmlspecialchars($row["created_at"]) ?></small></li>
<?php endwhile; ?>
</ul>
<script>
  const t = document.getElementById("t"), b = document.getElementById("b");
  t.addEventListener("input", () => { b.disabled = t.value.trim() === ""; });
</script>

Two habits in there are worth keeping for your own work. The note goes into the database through a prepared statement (prepare and bind_param), so what a visitor types can never rewrite your SQL. And everything that goes back onto the page is passed through htmlspecialchars, so a note that contains HTML shows up as text and does not run.

The Files tab showing the folder /home/agent/site with one file, index.php, and Download and Save to assets buttons
The Files tab. Folders you create stay on the computer's disk.

5. Run it

PHP can serve a folder by itself, which is fine for an assignment. Start it on port 8000:

php -S 0.0.0.0:8000 -t /home/agent/site

Leave that running while you try the page. In step 8 we hand the job to awx so you do not have to babysit it, and we will stop this copy first, because two programs cannot share one port.

Open the Previews tab. Under Share a web server enter the port, 8000, choose how long the link should work, and press Create link. The address appears in a box. Copy it and press Done. You can see it again later under Active links.

A dialog titled Your link showing an address ending in awanbox.com, with Copy and Done buttons
Anyone who has the link can open your page until it expires.

A new link lasts from one hour to seven days, which is right for a quick demo. For a link that should not expire while you are marking, press Keep always next to it in Active links. It then works until you press Revoke. The date the page shows afterwards is years away, and that is expected.

The Active links table with the link, its port and expiry, a Copy button and three buttons: Keep 1 more hour, Keep always and Revoke
Every link is listed with its address. Keep always, Keep 1 more hour, or Revoke when you are done.

7. Give it a name people can type

A random address is hard to read out in a lab. Under Custom names pick a short name and the port, and you get an address such as myassignment.awanbox.com. It has no expiry: it stays until you remove it. You can have three, and names that look like part of awx itself, such as www or admin, are refused.

The Custom names card with a list showing myassignment.awanbox.com on port 8000 and a Remove button
A name that is yours, for as long as you want it.

Here is one that is real. This page runs on a small awx computer and answers to its own custom address. It was made by following these steps, and it stays up the way step 8 describes.

https://classnotes.awanbox.com/
The Class notes page opened at classnotes.awanbox.com, showing three notes
A live example: classnotes.awanbox.com. The page is read-only and the database user behind it can only read.

8. Keep it up while the computer is on

Two things can make the page disappear: the computer going to sleep, and the program stopping. Both have a setting.

Sleep. An awx computer goes to sleep after 30 minutes without activity, and a visit to your link counts as activity. A quiet link at three in the morning does not. Under Settings, Power, tick Keep it running until my credit runs out (on the paid plan it reads Never stop it for being idle), and the computer stays on until you stop it or your credit is gone. More in why a computer sleeps, and how to keep it running.

The Power card in Settings with the switch Keep it running until my credit runs out ticked
Settings, Power. This is what keeps the link working through the night, and it uses credit every hour on the Free plan.

The program. If your PHP server or your database stops, so does the page. On the Previews tab the Services card keeps a command running for you. First stop the copies you started by hand: press Ctrl+C in the terminal where PHP is running, and type sudo service mariadb stop. Then add the web server and the database as two services:

web   php -S 0.0.0.0:8000 -t /home/agent/site
db    sudo mysqld_safe --user=mysql

If a service stops, it starts again a few seconds later, and both come back by themselves whenever the computer starts. We tested this: we stopped the computer, started it again, and eight seconds later the page was serving its notes. The notes were still there because the database lives on the computer's disk. Use the same Keep this computer awake option on the service to get the same effect as the Power setting.

The Services card listing two running services, web and db, both marked always on, with a form to add another
Two services, both running. The state column says what is running now.

9. What your lecturer sees

They open the address on whatever they have: a laptop, a phone, the lab PC. There is nothing to install and nothing to configure.

The Class notes page on a phone screen
The same page on a phone.

Before you send the link

A note on limits

The link works while the computer is on. If it is ever stopped, start it from the Computers page and the services come back. On the Free plan a computer that stays on uses credit every hour (Small is RM0.03 an hour, about RM22 a month), so keep it on only while you need the link. The paid plan runs for free.

New to awx? Why we think you can leave XAMPP behind is the short version of this post, and awx accounts are approved by hand for now, so sign in with Google and confirm your email first.

Keep reading

Awi the cat agent types at a desk

Awi, signing off.

← All posts