Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

When you can’t find the source of the problem When registering on HULEDET.com, u

ID: 3822620 • Letter: W

Question

When you can’t find the source of the problem

When registering on HULEDET.com, users input their birthday information. The information is parsed to three columns (M, D, Y). In some cases, the data does not store correctly. There is no discernible pattern to when. Explain how you would go about solving this problem.

Locate the registration form on HULEDET.com and HULEDET.com/ShareTheLove. For each form, identify the location of the file that contains the code and validation information for the form. (Hint: It may not be a JS file)

Hard coded vs. User Input

The following script supports our user registration function. Unfortunately, the zip code field is currently storing in our database as 0, rather than the user input. (A) Identify and fix the error. (B) Change $user_registervia = 'website' to input the current URL instead of the ‘website’.

    private $MasterID;

    private $CertificateH;

    public $email_address;

    private $birthday, $birthmonth, $birthyear;

    private $BirthdayDeployment, $belated = 'n';

    public $Birthday;

    public $IPAddress = '';

    public $zipcode = 0, $state = '', $City = '', $country = 'USA';

    private $source1 = 100001, $SourceName = 'HULEDET', $source = 'HULEDET.com';

    public $Source;

    public $registration = 900001, $registration_page = 'huledet.com';

    private $fname = '', $lname = '';

    public $name = '';

    public $type = 'user';

    public $gender = '';

    private $password;

    private $dbh;

    private $Status_of_subscriber = 'subscribed';

    public $status = '1';

    public $foreign_zipcode = '';

    public $user_registervia = 'website';

Missing Information in query

Our redemption system allows business clients to login, type in the certificate number they’re being presented with (CertificateH), and verify its validity. The system is to check that the same certificate has not been used within the last 60 days, and that it has not been used at the same location (Source1). However, an initial draft only checked against prior usage of the certificate number, not specific to the business.

Below you’ll see the query used. Please update the query to ensure that the user receives a “That code has been used already” message ONLY when it’s been used in the last 60 days at the same Source1 number.

$timeframe = date('Y-m-d H:i:s', strtotime('-60 days'));

$sql_query = "SELECT * FROM hul_redemption_history WHERE `CertificateH`='$certificate' AND RedeemedOn > '$timeframe'";

$res = mysql_query($sql_query, $sql);

if (!$res) {

    $_SESSION['error'] = 'Sorry, our server seems to be down. We cannot validate at this time.';

    header('Location:validate.php');

    exit();

if (mysql_num_rows($res) > 0) {

    $_SESSION['error'] = 'That code has been used already.';

    header('Location: validate.php');

    exit();

} else {

    unset($_SESSION['error']);

    $_SESSION['valid'] = true;

    header('Location: redeem.php');

    exit();

Importing data from a CSV file to a MySQL table:

We currently have a CSV file, named CSV1.csv with the following fields:

                  SourceNumber

                  Name

                  Address

                  City

                  State

                  Zip

A server based MySQL table named TableOne in a database named Database1 has the same fields, but is missing some of the information.

Write a script that imports data from the CSV file into the MySQL table where the SourceNumber is the unique id.

Explanation / Answer

Hi, please find the solution below

part 1: seperate Date of bith into dtae month and year using sub-string method and then add individual to data to their columns in DB

part 2: site validation script
HULEDET.com : home_validation.js
HULEDET.com/ShareTheLove : sharethelove_validation.js

part3:Hard coded vs. User Input
public $zipcode = 0 - Should be intialised to blank or null. like public $zipcode = '';
and then it should be updated with the value of zipcode from the form.

$user_registervia = $_SERVER['REQUEST_URI']

part4:
please update $timeframe = date('Y-m-d H:i:s', strtotime('-60 days')); to
$timeframe = strtotime('Y-m-d H:i:s -60 days');

part 5:
<?php

//database connection details that is to be connected
$connect = mysql_connect('localhost','root','password');

//throw error if not able to connect
if (!$connect) {
die('Could not connect to MySQL: ' . mysql_error());
}

//your database name
$cid =mysql_select_db('dbname',$connect);

// path where your CSV file is located
define('CSV_PATH','path to csv file like c:/something/something');

// Name of your CSV file
$csv_file = CSV_PATH . "test.csv"; //file name here using test.csv


if (($handle = fopen($csv_file, "r")) !== FALSE) {
fgetcsv($handle);   
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
for ($c=0; $c < $num; $c++) {
$col[$c] = $data[$c];
}

$col1 = $col[0];
$col2 = $col[1];
$col3 = $col[2];

// SQL Query to insert data into DataBase
$query = "INSERT INTO csvtbl(ID,name,city) VALUES('".$col1."','".$col2."','".$col3."')";
$s = mysql_query($query, $connect );
}
fclose($handle);
}

echo "File data successfully imported to database!!";
mysql_close($connect);
?>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote