diff --git a/Index.php b/Index.php new file mode 100644 index 0000000..c90a0b5 --- /dev/null +++ b/Index.php @@ -0,0 +1,354 @@ + + + + + + + + + + + Simple Sidebar - Start Bootstrap Template + + + + + + + + + + + + +
+ + + + + + +
+
+ + +Friends Who Program Together Stay Together + +

Code-Mates

+

This blog is to document Code_Mates, a programming training group that meets every Saturday. We are based in Austin.

+

There are four people. Matt Elliot (Developer 1) and +Tim Macaulay-Robinson (Developer 2) who have 20 years+ each experience. +Vicky Barnato (me) & Travis Austin who are non techs. Both of us come from +BA backgrounds and are programming novices.

+ +

Our goals: +Matt Elliot: Enhance tech communication and training skills by getting two civilians ready for programming jobs in one year. +Tim Macaulay-Robinson: Ditto.

+ +Vicky Barnato (me) & Travis Austin: Travis wants to move from Business Analysis to programming. +

+I want to be less dependent on developers’ explanations to understand how technology works. +This blog documents the projects and tasks that Tim and Matt set Travis and me to teach us. +These will be basic tasks at first. Readers with programming experience may find the first couple of posts too basic.

+

Please be patient we are novices! The first part of this post documents how I attempted to create an online guestbook form. +Please let me know if you see any mistakes or want additional explanations. +SQL was used for the database, html for the form and PHP to connect the two.

+ +The task was broken down by Tim into these steps: +
  1. Create database "guestbook" with 1 table "guest_" + - Guest name should be a text column
  2. +
  3. Create html form, text input, and button + - form should post data to php file insert_guest.php
  4. +
  5. Open connection to mysql using php mysql
  6. +
  7. Insert guest name into database + - write the insert statement to insert the guests name into the database + - submit the query to the database using the php mysql connection
  8. +
+ +

My code:

+ + + +       CREATE DATABASE guestbook2;

+      //You should see this message: “Query OK, 1 row affected (0.00 sec)”

+        USE guestbook2

+      //You should see this message “Database changed”

+        CREATE TABLE guest ( + guestID int, + guestname text, + sign_date date, + comments varchar(30), + reason varchar(30) + );

+      //You should see this message "Query OK, 0 rows affected (0.01 sec)"

+ +

Below is the html form guestbook2.php where guests will input data:

+ +

+

+

+ +

+

+

survey:

+ +

Guest Name:

+

+

+

Did you have a good stay? +

+

why or why not?

+

+

+

+

+


+

+

Guests staying at hotel - See if you know any! +

+


+ This is how happy you will be if you meet an old friend at the hotel +
+

+

+

+

+

+

+ +

Below is the code from insert_guest.php file which sets up the connection between the guestbook2 database and the html form

+ +

      $conn = mysqli_connect("localhost","username","password","guestbook2");

+

      //you will need to input username and password to set up the connection

+ +

      // Check connection

+

      if (mysqli_connect_errno())

+

      { + echo "Failed to connect to MySQL: " . mysqli_connect_error();

+

      }

+

      // not used connection

+

      // $myPDO = new PDO('mysql:host=localhost;dbname=guestbook2', 'username', 'password');

+ +

      if ($_POST) {

+ +

      $sql="INSERT INTO guest (guestname, comments, reason) VALUES ('".$_POST['guestname']."',       '".$_POST['comment']."', '".$_POST['reason']."')";

+ +

      if ($conn->query($sql) === TRUE) {

+

      echo "New record created successfully";

+

       }       else {

+

        echo "Error: " . $sql . "
      " . $conn->error;

+

      } + } + ?>

+ +

+ +

+

+ +

+

+

+

+ +

+

+ +

+ +

+ +

+

+ + +
+
+
+
+
+

Clean Blog

+ A Blog Theme by Start Bootstrap +
+
+
+
+
+ + + + +
+ + +

+ +

+

+

+

+ +

+

+ + + + diff --git a/schema.sql b/schema.sql index e4c9405..bc5e1fe 100644 --- a/schema.sql +++ b/schema.sql @@ -1,2 +1,2 @@ -create database cm_blog; - +CREATE TABLE cm_blog.article + (article_id int NOT NULL AUTO_INCREMENT Primary Key, author_user_id int NOT NULL AUTO_INCREMENT Primary Key, title varchar(35), body text, publish_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP);