Question

Implement a PHP function that reads in input a string from the user and store it in a table (e.g....

  • Implement a PHP function that reads in input a string from the user and store it in a table (e.g., in a field called "Content Name").
  • The function should be able to read the content of the file and store it in a table (e.g., in a field called "File Content").
  • The web application should be able to implement a logic to log in and sign up users.
    • Each user will have exclusive access to her/his uploaded material.
    • When a user logs in, all her/his private content will be displayed on the web page.
      • If no user has logged in yet, no information from the database are printed on the webpage.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

The problem has been resolved. The question is too big and the approach that have used in solution is little different. The better solution is to store a file into db is, we store the path of file into db and copy the file into a path.

Code for get value from user and insert into db.

----------------------------

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="$1">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" type="text/css" href="style.css">

<title>test</title>

<?php
//add DB connect file here
?>

</head>
<body>
<?php
if(isset($_POST['save'])){
$sql = "INSERT INTO FIELDCALLED (contentName)
VALUES ('".$_POST["contentName"]."')";
}

?>

<form method="post">
<label id="first"> Content Name:</label><br/>
<input type="text" name="contentName"><br/>

<button type="submit" name="save">save</button>

</form>

</body>
</html>

------------------------

Code for upload a file and insert into db.

---------------------------------------

fileupload.php

----------------------------

<?php
$path = "home/file";
$path = $path . basename( $_FILES['Filename']['name']);

$Filename=basename( $_FILES['Filename']['name']);

if(move_uploaded_file($_FILES['Filename']['tmp_name'], $path)) {

echo "File ". basename( $_FILES['Filename']['name']). " has been uploaded";
$link = mysqli_connect("localhost", "root", "", "");
$sql = "INSERT INTO Table-Name (Column-Name)
   VALUES ('$filename')" ;
} else {
  
echo "Error";
}

?>

<form method="post" action="fileupload.php" enctype="multipart/form-data">
<p>File:</p>
<input type="file" name="Filename">
  
<input TYPE="submit" name="upload" value="Add"/>
</form>

---------------------------------------

The problem has been resolved, I hope you will like the solution. If you have any question or query regarding this problem or other, please comment below and give the positive rating.

Thank You!! Happy Learning!! !!

Add a comment
Know the answer?
Add Answer to:
Implement a PHP function that reads in input a string from the user and store it in a table (e.g....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You need to implement a web application that is split in three parts, namely, Webpage, PHP and My...

    You need to implement a web application that is split in three parts, namely, Webpage, PHP and MySQL. Each of them will be used accordingly to solve a simple problem described below. Remember to implement the logic in the most secure way of your knowledge. PHP Implement a PHP function that reads in input a string from the user and store it in a table (e.g., in a field called "Content Name"). The function should be able to read the...

  • This code should be written in php. Write a program that allows the user to input...

    This code should be written in php. Write a program that allows the user to input a student's last name, along with that student's grades in English, History, Math, Science, and Geography. When the user submits this information, store it in an associative array, like this: Smith=61 67 75 80 72 where the key is the student's last name, and the grades are combined into a single space-delimited string. Return the user back to the data entry screen, to allow...

  • Helpp: Make an application Protocol Application log for text messages In this task, an application protocol for sending...

    Helpp: Make an application Protocol Application log for text messages In this task, an application protocol for sending and retrieving text messages is to be developed. A client (eg app on a smartphone) communicates with an application on a web server running a database of user data (username and password) and messages (user name of the sender, user name of the recipient, message text). The client should be able to perform the following actions: Register a new user Log in...

  • Write a program, called wordcount.c, that reads one word at a time from the standard input....

    Write a program, called wordcount.c, that reads one word at a time from the standard input. It keeps track of the words read and the number of occurrences of each word. When it encounters the end of input, it prints the most frequently occurring word and its count. The following screenshot shows the program in action: adminuser@adminuser-VirtualBox~/Desktop/HW8 $ wordCount This is a sample. Is is most frequent, although punctuation and capitals are treated as part of the word. this is...

  • Please provide a SQL Table diagram with their relationships based on the following prompt: Consider the...

    Please provide a SQL Table diagram with their relationships based on the following prompt: Consider the design of a database for an online store. Each item is identified by a unique item ID, a title, a description of the item, the date the item is posted, price, and a list of categories (each category is a single word in lower cases). Only registered users can post, buy, and review an item. Each registered user is identified by a user ID,...

  • Please give me an idea on how to improve the JAVA program below which is a student grading system for future works. The current function is Users input their details and marks and the results could be...

    Please give me an idea on how to improve the JAVA program below which is a student grading system for future works. The current function is Users input their details and marks and the results could be printed on the transcript text field and save to a database which is in text file form. The delete button is for deleting the table rows, reset button is to clear all text field. average button is to calculate all result and send...

  • Consider the following C++ program. It reads a sequence of strings from the user and uses...

    Consider the following C++ program. It reads a sequence of strings from the user and uses "rot13" encryption to generate output strings. Rot13 is an example of the "Caesar cipher" developed 2000 years ago by the Romans. Each letter is rotated 13 places forward to encrypt or decrypt a message. For more information see the rot13 wiki page. #include <iostream> #include <string> using namespace std; char rot13(char ch) { if ((ch >= 'a') && (ch <= 'z')) return char((13 +...

  • Instructions: Consider the following C++ program. It reads a sequence of strings from the user and...

    Instructions: Consider the following C++ program. It reads a sequence of strings from the user and uses "rot13" encryption to generate output strings. Rot13 is an example of the "Caesar cipher" developed 2000 years ago by the Romans. Each letter is rotated 13 places forward to encrypt or decrypt a message. For more information see the rot13 wiki page. #include <iostream> #include <string> using namespace std; char rot13(char ch) { if ((ch >= 'a') && (ch <= 'z')) return char((13...

  • In Python and in one file please. (Simple functions with an expressions) Create a function called...

    In Python and in one file please. (Simple functions with an expressions) Create a function called load_inventory(filename). The filename argument in this case specifies the name of a file that contains all the inventory/product information for the store, including product names, descriptions, prices, and stock levels. This function should clear any information already in the product list (i.e., a fresh start) and then re-initialize the product list using the file specified by the filename argument. You can structure your file...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT