With this I'm needing to start off by logging in. This is done by putting in the email of a customer and pressing the login button (this is the customer_login.php page). The login button goes through the index.php page and then goes to the product_register.php page. Once the product_register.php page is opened, the first name of the customer that is associated with the email is automatically shown, then there is a drop down that is used to select the product that is being registered. Then when you click on the register product button it is to show a statement on the same product_register.php page stating "Product (product name that was inputted in the drop down) was registered successfully. How can I get the coding that I have now to be able to do that?
How to get the search bar to work correctly
I'm needing to be able to get a search bar to work in PHP using HTML. I have done some coding, but cannot fully grasp how to do it. What can I do to get the search bar to work? I am needing to be able to search for a last name and have it display the name. There is no set first name or last name, just the name of the person all in one (if that makes sense)
I have attached the files that I am using.
Executing a button in PHP
Reposting again due to coding problem, I have attached the files
I am having trouble getting my button to submit the words in the text box over to the table on another page. What can I do to fix this?
Thanks
Button not working correctly
I have attached all of the coding needed
I'm using PHP to design a website. The problem that I am facing is that, the button on the add products page isn't taking the inputs and putting them on the products list page. I'm wondering what I can do to get the button to work correctly.
Here is the index.php page
<?php
require('../model/database.php');
require('../model/product_db.php');
$action = filter_input(INPUT_POST, 'action');
if ($action === NULL)
$action = filter_input(INPUT_GET, 'action');
if ($action === NULL)
$action = 'list_products';
if ($action == 'list_products')
// Get product data
$query= 'SELECT productCode, name, version, releaseDate FROM products WHERE productCode = :product_code;'
$statement = $db->prepare($query);
$statement->bindValue(':prodct_code', $product_code);
$statement->execute();
$products = $statement->fetchAll();
$statement->closeCursor();
$products = get_products();
// Display the product list
$query = 'SELECT * FROM products WHERE productCode = :product_code';
$statement = $db->prepare($query);
$statement->bindValue(':product_code', $product_code);
$statement->execute();
$product = $statement->fetch();
$statement->closeCursor();
include('product_list.php');
else if ($action == 'delete_product')
$product_code = filter_input(INPUT_POST, 'product_code');
if ($product_code != false)
$query = 'DELETE FROM products WHERE productCode = :product_code';
$statement = $db->prepare($query);
$statement->bindValue(':product_code', $product_code);
$success = $statement->execute();
$statement->closeCursor();
//Display the Product List page
include('product_list.php');
header("Location: .");
else if ($action == 'show_add_form')
// Add the product to the database
$query = 'INSERT INTO products (productCode, name, version, releaseDate) VALUES (:code, :name, :version, :release_date)';
$statement = $db->prepare($query);
$statement->bindValue(':code', $code);
$statement->bindValue(':name', $name);
$statement->bindValue(':version', $version);
$statement->bindValue(':release_date', $release_date);
$statement->execute();
$statement->closeCursor();
//Display the Product List page
include('product_list.php');
else if ($action == 'add_product')
$code = filter_input(INPUT_POST, 'code');
$name = filter_input(INPUT_POST, 'name');
$version = filter_input(INPUT_POST, 'version', FILTER_VALIDATE_FLOAT);
$release_date = filter_input(INPUT_POST, 'release_date');
// Validate the inputs
if ( $code === NULL || $name === FALSE ||
$version === NULL || $version === FALSE ||
$release_date === NULL)
$error = "Invalid product data. Check all fields and try again.";
include('../errors/error.php');
else
add_product($code, $name, $version, $release_date);
header("Location: .");
?>
the product_add.php page
<?php include '../view/header.php'?>
<main>
<h1>Add Product</h1>
<form action="product_list.php" method="post" id="aligned">
<input type="hidden" name="action" value="add_product">
<label>Code:</label>
<input type="text" name="code"><br>
<label>Name:</label>
<input type="text" name="name"><br>
<label>Version:</label>
<input type="text" name="version"><br>
<label>Release Date:</label>
<input type="text" name="release_date" />
<label class="message">Use 'yyyy-mm-dd' format</label><br>
<label> </label>
<input type="submit" value="Add Product" /><br>
</form>
<p><a href="product_list.php">View Product List</a></p>
</main>
<?php include '../view/footer.php'; ?>
the product_list.php page
<?php include '../view/header.php'?>
<main>
<h1>Product List</h1>
<!-- display a table of products -->
<table>
<tr>
<th>Code</th>
<th>Name</th>
<th>Version</th>
<th>Release Date</th>
<th> </th>
</tr>
<?php foreach ($products as $product) : ?>
<tr>
<td><?php echo htmlspecialchars($product['productCode']); ?></td>
<td><?php echo htmlspecialchars($product['name']); ?></td>
<td><?php echo htmlspecialchars($product['version']); ?></td>
<td><?php echo htmlspecialchars($product['releaseDate']); ?></td>
<td><form action="index.php" method="post">
<input type="hidden" name="action"
value="delete_product">
<input type="hidden" name="product_code"
value="<?php echo htmlspecialchars($product['productCode']); ?>">
<input type="submit" value="Delete">
</form></td>
</tr>
<?php endforeach; ?>
</table>
<p><a href="product_add.php">Add Product</a></p>
</main>
<?php include '../view/footer.php'; ?>
and the product_db.php page
<?php
function get_products()
global $db;
$query = 'SELECT * FROM products
ORDER BY name';
$statement = $db->prepare($query);
$statement->execute();
$products = $statement->fetchAll();
$statement->closeCursor();
return $products;
function get_products_by_customer($email)
global $db;
$query = 'SELECT products.productCode, products.name
FROM products
INNER JOIN registrations ON products.productCode = registrations.productCode
INNER JOIN customers ON registrations.customerID = customers.customerID
WHERE customers.email = :email';
$statement = $db->prepare($query);
$statement->bindValue(':email', $email);
$statement->execute();
$products = $statement->fetchAll();
$statement->closeCursor();
return $products;
function get_product($product_code)
global $db;
$query = 'SELECT * FROM products
WHERE productCode = :product_code';
$statement = $db->prepare($query);
$statement->bindValue(':product_code', $product_code);
$statement->execute();
$product = $statement->fetch();
$statement->closeCursor();
return $product;
function delete_product($product_code)
global $db;
$query = 'DELETE FROM products
WHERE productCode = :product_code';
$statement = $db->prepare($query);
$statement->bindValue(':product_code', $product_code);
$statement->execute();
$statement->closeCursor();
function add_product($code, $name, $version, $release_date)
global $db;
$query = 'INSERT INTO products
(productCode, name, version, releaseDate)
VALUES
(:code, :name, :version, :release_date)';
$statement = $db->prepare($query);
$statement->bindValue(':code', $code);
$statement->bindValue(':name', $name);
$statement->bindValue(':version', $version);
$statement->bindValue(':release_date', $release_date);
$statement->execute();
$statement->closeCursor();
function update_product($code, $name, $version, $release_date)
global $db;
$query = 'UPDATE products
SET name = :name,
version = :version,
releaseDate = :release_date
WHERE productCode = :product_code';
$statement = $db->prepare($query);
$statement->bindValue(':name', $name);
$statement->bindValue(':version', $version);
$statement->bindValue(':release_date', $release_date);
$statement->bindValue(':product_code', $code);
$statement->execute();
$statement->closeCursor();
?>
I've had to take out the curly brackets to be able to get the code to post.
How does the firewall on the Linux system work?
#!/bin/bash
iptables -F
iptables -t nat -F
iptables -X
iptables -t nat -X
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth1 -p tcp -s 192.168.167.0/24 --dport 22 \
-m state --state NEW -j ACCEPT
iptables -A INPUT -i eth1 -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A OUTPUT -o eth1 -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp -d 133.172.114.17 --dport 25 \
-j DNAT --to-destination 192.168.167.23:25
iptables -t nat -A POSTROUTING -o eth0 -p tcp -s 192.168.167.0/24 \
-j SNAT --to-source 133.172.114.17
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -i eth1 -p tcp -s 192.168.167.0/24 --dport 80 \
-m state --state NEW -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp -s 192.168.167.0/24 --dport 443 \
-m state --state NEW -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp -d 192.168.167.23 --dport 25 \
-m state --state NEW -j ACCEPT
iptables -A FORWARD -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
With this firewall script, I'm needing to answer this question:
For the following four groups of iptables commands, explain:
the overall effect of each group of commands, and
the purpose of each command within the group.
- lines 12 and 18,
- lines 13 and 19.
- lines 21, 32 and 34.
- lines 23, 28, 30 and 34.
a primary-expression is expected before ‘)’ on line 32 to 37
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
struct staffTWB {
string staffName;
int staffProf;
};
void printEntry(staffTWB);
int main() {
string staffName;
int staffProf;
while (staffName != "done") {
cout << "Please enter a staff name(done to leave the program):" << endl;
getline(cin, staffName, '\n');
if (staffName == "done") {
break;
}
else {
cout << "Please enter the profession of " << staffName << "\n";
cin >> staffProf;
cin.ignore();
if (staffProf >= 1 && staffProf <= 4) {
**printEntry(staffTWB);**
}
else {
cout << "Wrong entry!\n";
cin.clear();
cin.sync();
}
}
}
The line with the astrix is where the error is occurring from