Username/password is incorrect."; } } } // A function to register a new user function register () { if (isset($_REQUEST['username'])) { global $con; // removes backslashes $username = stripslashes($_REQUEST['username']); //escapes special characters in a string $username = mysqli_real_escape_string($con,$username); $email = stripslashes($_REQUEST['email']); $email = mysqli_real_escape_string($con,$email); $password = stripslashes($_REQUEST['password']); $password = mysqli_real_escape_string($con,$password); $query = "INSERT into users (userLogin, userPass, userEmail) VALUES ('$username', '$password', '$email')"; $result = mysqli_query($con,$query); // checks if the username or email addresse is already taken if ($result) { echo "

You are registered successfully.


Click here to Login
"; } elseif (mysqli_errno($con) == 1062) { echo "

Username or Email already taken.

"; } } } // A function to post a demand function pbinsert ($con) { if (isset($_POST['submit'])) { global $con; //$userId = $_POST['userId']; $piecesMax = $_POST['piecesMax']; $piecesMin = $_POST['piecesMin']; $date = $_POST['date']; $text = $_POST['text']; // Inserts Data into Database $sql = "INSERT INTO demand ( piecesMax, piecesMin, text, date) VALUES ('$piecesMax', '$piecesMin', '$text', '$date')"; $result = mysqli_query($con, $sql) or die(mysqli_error($con)); } } // A function to insert the own posts from the database into the webside function pbget($con) { global $con; $sql = "SELECT * FROM demand"; $result = mysqli_query($con, $sql); while($row = $result->fetch_assoc()){ echo "

"; echo $row['date'] . "
"; echo $row['text'] ."
" , "
Maximum
"; echo $row['piecesMax'] ."
Minimum
"; echo $row['piecesMin']; echo "

"; } } // A function to edit a demand function editpost($con) { if (isset($_POST['submit'])) { global $con; $userId = $_POST['userId']; $demandId = $_POST['demandId']; $piecesMax = $_POST['piecesMax']; $piecesMin = $_POST['piecesMin']; $date = $_POST['date']; $text = $_POST['text']; // Inserts Updates Database $sql = "UPDATE demand SET message='$message' WHERE demandId='$demandId'"; $result = mysqli_query($con, $sql) or die(mysqli_error($con)); header("Location: board.php"); } } // A function to delete a post function deletepost($con) { if (isset($_POST['deletepost'])) { global $con; $demandId = $_POST['demandId']; // Delete Post from Database $sql = "DELETE FROM demand WHERE demandId='$demandId'"; $result = mysqli_query($con, $sql) or die(mysqli_error($con)); header('Location: board.php'); } } ?>