\$servername= ".$servername."   "; echo "\$dbname= ".$dbname."   "; echo "\$tablename= ".$tablename."   "; /* echo "\$username= ".$username."
"; echo "\$password= ".$password."
"; */ OpenSupporterDatabase(); } /////////////////////////////////////// // FORM FIELDS ENTRY // echo "
".document.getElementById('emailkey').value."
"; //////////////////////////////////////////////// // Init variables // $IDErr = $fnameErr = $mnameErr = $lnameErr = $suffixErr = $emailErr = $mailaddrErr = $cityErr = $stateErr = $ZIPErr = $instErr = $commentErr = ""; $ID = $fname = $mname = $lname = $suffix = $email = $mailaddr = $city = $state = $ZIP = $inst = $comment = ""; $done=0; $femail = ""; $fID = $ffname = $$flname = ""; ?>
	
	
	 />
	
Email: ID num:
Submit Lookup
"; // Do stuff ////////////////////////////////// // LOOKUP member by email or ID number // Get row load and display data // echo "email= ".$femail; $stmt = $conn->prepare("SELECT * FROM $tablename WHERE supp_email=?"); $stmt->execute([$femail]); $user = $stmt->fetch(); echo "
ID ".$user[0]; $suppID = $user[0]; echo $suppID; $suppStatus=$user[1]; echo $suppStatus; $suppEmail = $user[2]; $suppFname= $user[3]; $suppMname = $user[4]; $suppLname = $user[5]; $suppSuffix = $user[6]; $suppAddr = $user[7]; $suppCity = $user[8]; $suppState = $user[9]; $suppZIP = $user[10]; $suppInstructio = $user[11]; $suppComment = $user[12]; $suppDcreate = $user[13]; $suppDverify = $user[14]; $suppDpaid = $user[15]; $suppPMT = $user[16]; $suppDremind = $user[17]; $suppDinact = $user[18]; $ffname="eddd"; echo "
suppFname=".$suppFname; // $supp = $user[]; // LoadElements(); ?>
Status: 1 char First Name: Mid Name: Last Name: Suffix: Addr: City: State: ZIP: Instructor: Yes Comment:
"> ID num: Status: 1 char First Name: Mid Name: Last Name: Suffix: Addr: City: State: ZIP: Instructor: Yes Comment: */ ?> User0= ".$user[0]; echo "
User1= ".$user[1]; echo "
User2= ".$user[2]; echo "
User3= ".$user[3]; echo "
User4= ".$user[4]; echo "
User5= ".$user[5]; echo "
User6= ".$user[6]; echo "
User7= ".$user[7]; echo "
User8= ".$user[8]; echo "
User9= ".$user[9]; */ echo "
End Submit Lookup
"; // Do stuff } else if( $_POST['SubmitUpdate'] ) { echo "
SubmitUpdate
"; // Do stuff /* if (empty($_POST["fname"])) { $fnameErr = "First Name is required"; } else { $fname = test_input($_POST["fname"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z-' ]*$/",$fname)) { $fnameErr = "Only letters and white space allowed"; } } if (empty($_POST["lname"])) { $lnameErr = "Last Name is required"; } else { $lname = test_input($_POST["lname"]); // check if name only contains letters and whitespace // if (!preg_match("/^[a-zA-Z-' ]*$/",$lname)) { // $lnameErr = "Only letters and white space allowed"; // } } if (empty($_POST["mailaddr"])) { $mailaddrErr = "Mailing Address is required"; } else { $mailaddr = test_input($_POST["mailaddr"]); // check if name only contains letters and whitespace // if (!preg_match("/^[a-zA-Z]{1,10}$/",$name)) { // $nameErr = "Only alphanumeric and white space allowed"; } if (empty($_POST["city"])) { $cityErr = "City is required"; } else { $city = test_input($_POST["city"]); // check if city only contains alphanumeric and whitespace // if (!preg_match("/^[a-zA-Z-' ]*$/",$city)) { // $cityErr = "Only letters and white space allowed"; } if (empty($_POST["state"])) { $stateErr = "State is required"; } else { $state = test_input($_POST["state"]); // check if state only contains alphanureic and whitespace // if (!preg_match("/^[a-zA-Z-' ]{1,10}$/",$state)) { // $stateErr = "Only letters and white space allowed"; } if (empty($_POST["inst"])) { $inst = "0"; } else { $inst = "1"; } // $inst = test_input($_POST["inst"]); if (empty($_POST["ZIP"])) { $ZIPErr = "ZIP is required"; } else { $ZIP = test_input($_POST["ZIP"]); } if (empty($_POST["comment"])) { $commentErr = "Comment is required"; } else { $comment = test_input($_POST["comment"]); } */ echo "
End SubmitUpdates
"; // Do stuff } //END SubmitUpdate ENTRIES ?> query("SELECT count(*) FROM $tablename")->fetchColumn();$text = "Select"; echo "
row count= ".$count."
"; if(count < 1) break; // out of while() // see if email address is already used $stmt = $conn->prepare("SELECT * FROM $tablename WHERE supp_email=?"); $stmt->execute([$email]); $user = $stmt->fetch(); if ($user) { echo "user=".$user."
"; // email found } else { echo "no email
"; // or not echo "user=".$user."
"; // email found } } */ function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } function checksum($data) { return "ABCD"; } //////////////////////////////// // PDO // function OpenSupporterDatabase() { try { global $servername; global $username; global $password; global $dbname; global $tablename; global $conn; if ($conn != NULL) $conn = NULL; $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // see how many rows of data are in the table $count = $conn->query("SELECT count(*) FROM $tablename")->fetchColumn();$text = "Select"; echo "

Supporter Database Update:  Total Rows= ".$count."

"; $stmt = $conn->prepare("SELECT * FROM $tablename WHERE supp_email=?"); $stmt->execute([$email]); $user = $stmt->fetch(); /* if ($user) { echo "user=".$user."
"; // email found } else { echo "no email
"; // or not echo "user=".$user."
"; // email found } */ // echo "
Conn2 is not NULL
"; //$sql = "INSERT INTO users (name, surname, sex) VALUES (?,?,?)"; //$stmt= $pdo->prepare($sql); //$stmt->execute([$name, $surname, $sex]); // //or you can chain execute() to prepare(): // //$sql = "INSERT INTO users (name, surname, sex) VALUES (?,?,?)"; //$pdo->prepare($sql)->execute([$name, $surname, $sex]); // /* $CDATE=date("Y/m/d"); $text = "Insert"; $sql = "INSERT INTO $tablename (supp_status, supp_email, supp_fname, supp_lname, supp_addr, supp_city, supp_state, supp_zip, supp_instructor, supp_comment, supp_dcreate) VALUES (?,?,?,?,?,?,?,?,?,?,?)"; $conn->prepare($sql)->execute(["C",$email, $fname, $lname, $mailaddr, $city, $state, $ZIP, $inst, $comment, $CDATE]); echo "New record created successfully"; */ } catch(PDOException $e) { echo $text."
"; echo $sql . "
" . $e->getMessage(); } } ////////////////////////////////////// // Close db and exit // $conn = null; //close db echo "
PDO connection closed ..."; ?>