QU – A website for making queues

For the project in cs class, I decided to create a website for queues. If you haven’t got the idea yet, a website for queues means that, anyone who wants can open a queue and people can decide to join the queue and virtually stand in line, instead of for example standing in line for ice cream, out in the sun.

Here is the link, try it and enjoy: http://qu.yaniv-kap.co.il/

As always, I dived to the project without any previous knowledge, specifically this time in php backend development and learned everything from examples I found online.

One problem I found especially entertaining is a problem with the redirect function in php, which just didn’t work at all. All the browser showed me when it tryed to redirect is a blank page.

After a lot of searching, I found out that 2 rules must be kept when it comes to using the header() function:

  1. Put the php section before the <!DOCTYPE html>.
  2. Delete all newlines before and after the php tags.

Example of using the header() function:

if ($_POST['name'] != '' && $_POST['code'] != ''){
$servername = "***";
$username = "***";
$password = "***";
$dbname = "***";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);

//check first if code exists
$sql = "SELECT * FROM queue WHERE code='" . $_POST['code'] . "'";
$result = $conn->query($sql);

if ($result->num_rows == 0)//if doesn't exist create.
$sql = "INSERT INTO queue(name, code) VALUES('". $_POST['name'] . "', '" . $_POST['code'] . "')";

header("Status: 301 Moved Permanently");
header("Location: http://qu.yaniv-kap.co.il/que_admin.php?code=" . $_POST['code']);


Leave a Reply

Your email address will not be published. Required fields are marked *