Skip to content

Commit

Permalink
test SQL connection for sms signup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrturner committed Feb 25, 2024
1 parent 06bfc72 commit ecccab5
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 39 deletions.
1 change: 1 addition & 0 deletions site/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function generateRelationsJson()
* all config options: https://getkirby.com/docs/reference/system/options
*/
return [
// 'debug' => true,
'debug' => false,
'panel' => [
'install' => true
Expand Down
89 changes: 50 additions & 39 deletions site/templates/signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,30 @@
<main class="main content-container index">

<section id="col1" class="intro" style="max-width: 60ch;">

<p>
Sign up to our very special, very weird SMS
newsletter. Intimate and candid connections with the quirky festival cohort, sent straight from the Audible Edge burner phone. No spam - just the occasional bit of mail art in your messaging app, especially around gig time. You can unsubscribe any time.
</p>
</section>

<section id="col2" class="description" style="max-width: 60ch;">

<details>
<summary>&#128274;</summary>
All data collected will be stored on a private SQL server for the duration of the festival and will not be shared with third parties.
</details>
</section>

<section id="col3" class="form" style="max-width: 60ch;">
<section id="col3" class="form">
<div class="sms_form">
<form method="post" action="<?= $page->url() ?>">
<label for="name">Preferred Name</label>
<input type="text" id="name" name="name" required>
<div class="field-group">

<label for="phone">Phone</label>
<input type="tel" id="phone" name="phone" required>
<label for="name">Preferred Name</label><br>
<input type="text" id="name" name="name" required>
</div>
<div class="field-group">
<label for="number">Phone</label><br> <input type="tel" id="number" name="number" required>
</div>


<?php
Expand All @@ -58,44 +67,46 @@
<button type="submit">Submit</button>
</form>
<?php
$name = ($_POST["name"]);
$number = ($_POST["number"]);
$dateAdded = date('Y-m-d H:i:s');

// Database connection parameters
$host = 'localhost';
$username = 'atcomau1_ae24';
$password = 'kk6aGGh7GrRdmCU';
$database = 'atcomau1_audible_edge_2024';
$usertable = "users";

$conn = mysqli_connect($host, $username, $password, $database);

// Check connection
if ($conn === false) {
die("Error: could not connect. " . mysqli_connect_error());
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = ($_POST["name"]);
$number = ($_POST["number"]);
$dateAdded = date('Y-m-d H:i:s');

$sql = "INSERT INTO $usertable (name, phone, date_added) VALUES ('$name', '$number', '$dateAdded');";
// Database connection parameters
$host = 'localhost';
$username = 'atcomau1_ae24';
$password = 'kk6aGGh7GrRdmCU';
$database = 'atcomau1_audible_edge_2024';
$usertable = "users";

if (mysqli_query($conn, $sql)) {
echo '<div class="form-container"><p class="form-text"> Records successfully added! Welcome to the Audible Edge 2022 text line.</p></div>';
} else {
echo '<div class="form-container"><p class="form-text">ERROR: Unable to execute $sql.</p></div>' . mysqli_error($conn);
}
$conn = mysqli_connect($host, $username, $password, $database);

mysqli_close($conn);
// Check connection
if ($conn === false) {
die("Error: could not connect. " . mysqli_connect_error());
}

// $config = include kirby()->root('config') . '/db.php';
//// Create a connection
// $conn = new mysqli($config['host'], $config['username'], $config['password'], $config['database']);
$sql = "INSERT INTO $usertable (name, phone, date_added) VALUES ('$name', '$number', '$dateAdded');";

// $conn = new mysqli($host, $username, $password, $database);
if (mysqli_query($conn, $sql)) {
echo '<div class="form-container"><p class="form-text">Records successfully added! Welcome to the Audible Edge text line.</p></div>';
} else {
echo '<div class="form-container"><p class="form-text">ERROR: Unable to execute $sql.</p></div>' . mysqli_error($conn);
}

//// Check connection
// if ($conn->connect_error) {
// die("Connection failed: " . $conn->connect_error);
// }
mysqli_close($conn);

// $config = include kirby()->root('config') . '/db.php';
//// Create a connection
// $conn = new mysqli($config['host'], $config['username'], $config['password'], $config['database']);

// $conn = new mysqli($host, $username, $password, $database);

//// Check connection
// if ($conn->connect_error) {
// die("Connection failed: " . $conn->connect_error);
// }
}
?>
<?php

Expand Down

0 comments on commit ecccab5

Please sign in to comment.