#!/usr/bin/perl use strict; use warnings; use DBI; #Declaire all variables now! my $customer_firstname; #Store the customers first name my $customer_lastname; #Store the customers last name my $customer_phone; #Store the customers main phone number my $customer_email; #Store the customers email address my $customer_date; #date that the entry was made my $customer_AcceptTerm; #Accept Term of use? my $customer_compman; #Store the computer manufaturer my $customer_compmodel; #Store the computer model my $customer_compModelNum; #Store the computer model number my $customer_errormsg; #Store any and all error messages displaied my $customer_os; #Store what OS is being used my $customer_probdesc; #Store the problem description my $customer_loginpw; #Store the password for the admin/root user my $customer_service; #Store what services need to be done. my $customer_barcode; #Store the barcode for the computer. my $database = "Repairs"; #Specify the database to be used my $hostname = "192.168.1.111"; #Connect to the MySQL server my $port = '3306'; #MySQL port my $user = 'csccrepairs'; #MySQL username my $password = 'repairshop'; #MySQL password my $dsn; my $dbh; system("clear"); #system("clear") only works on Unix based systems, need to come up with #something that works on windows print "Cleveland State CC Computer Repairs\n\n"; print "Version 0.2\n", "Copyleft 2009 Adam Jimerson & Andy Arp\n"; main(); #break here sub main() { print "----------------------------\n", "Main Menu, To make a selection specify the number for that action\n"; print "1. Add New Computer to Database\n"; print "2. Edit Computer Status in Database\n"; print "3. Remove a Computer from Database\n"; print "4. Look up Computer Information\n"; print "5. List All Repair Requests\n"; print "Action: "; my $option = ; chomp($option); if ( $option eq '1' ) { print_form(); } else { die "Unknown Action: $option\n"; } } sub print_form { print "\nCustomer Information\n", "-----------------------\n"; #Begin the customer information form print "Customer First Name: "; $customer_firstname = ; chomp($customer_firstname); print "Customer Last Name: "; $customer_lastname = ; chomp($customer_lastname); print "Customer Phone #: "; $customer_phone = ; chomp($customer_phone); print "Customer Email: "; $customer_email = ; chomp($customer_email); print "\nComputer Information\n", "-----------------------\n"; #Begin the computer information form print "Computer Manufacturer: "; $customer_compman = ; chomp($customer_compman); print "Computer Model: "; $customer_compmodel = ; chomp($customer_compmodel); print "Computer Model #: "; $customer_compModelNum = ; chomp($customer_compModelNum); print "Error Message (if any): "; $customer_errormsg = ; chomp($customer_errormsg); print "Operating System: "; $customer_os = ; chomp($customer_os); print "Problem Description: "; $customer_probdesc = ; chomp($customer_probdesc); print "Administrator/Root Login Password: "; $customer_loginpw = ; chomp($customer_loginpw); print "Computer Service Needed: "; $customer_service = ; chomp($customer_service); print "Barcode Number: "; $customer_barcode = ; chomp($customer_barcode); $customer_date = system('date'); db_add(); } sub db_add { #Insert values retreived from print_form() $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port"; $dbh = DBI->connect($dsn, $user, $password, {RaiseError => 1}); $dbh->do("INSERT INTO Repairs.computers VALUES (compManufacturer, compModel, compModelNum, OS,errorMsg , serviceNeeded, problemDescription, barcode, password) ($customer_compman, $customer_compmodel , $customer_compModelNum , $customer_os , $customer_errormsg , $customer_service , $customer_probdesc , $customer_barcode , $customer_loginpw"); $dbh->do("INSERT INTO Repairs.customers VALUES(firstname, lastname, email, phone, date) ($customer_firstname, $customer_lastname, $customer_email, $customer_phone, $customer_date"); $dbh->disconnect(); } exit 0;