<?php // get user information from the form // TODO expand values $username = $_POST["username"]; // array used to check all the values // TODO expand values // TODO add checks for the information $userinfo = array(); $userinfo[0] = $username; // register into the database registerDB($userinfo); //function to register the user function registerDB($username) { // connect to DB $con = mysqli_connect("mysql.cs.iastate.edu", "u30918", "NZXN5aAvuB", "db30918"); //check connection if (mysqli_connect_errno()) { echo "Failed to connect to database"; } else { //TODO //expand the query to include all the needed values mysqli_query($con, "INSERT INTO Users (Username) \n\t\t\tVALUES ({$username})"); } }
$lastnm = trim($_POST['lastnm']); // array used to check all the values // TODO expand values // TODO add checks for the information $userinfo = array(); $userinfo[0] = checkUN($username); $userinfo[1] = isPassOk($password); $userinfo[2] = checkPass($password, $matchpassword); for ($i = 0; $i < count($userinfo); $i++) { if ($userinfo[$i] == false) { $testRes = "false"; } } if ($testRes == "true") { // register into the database registerDB($username, $password, $firstnm, $lastnm); header('Location: /index.php'); } else { echo '<script type="text/javascript">alert("Invalid information")</script>'; sleep(3); header('Location: /register.php'); } //function to register the user //function registerDB($username){ function registerDB($username, $password, $firstnm, $lastnm) { // connect to DB //$con = mysqli_connect('mysql.cs.iastate.edu', 'u30918', 'NZXN5aAvuB', 'db30918'); //check connection /*if(!$con){ //echo "Failed to connect to database";