PHP
Review
For the Programming part:
1. How to connect to Database: connecting string, query string mysqli_connect(), mysqli_query()
2. mysqli_fatch_array() - records returned, with while loop
3. form and name of variables that can be retrieved in php file.=> $_POST, $_GET
4. all the variables that a php file can access: _GET, _POST, SEVER, ... global variables with respect to the get and post methods in the form.
5. Where (Which directory) you store the database connecting information? parallel to htdocs folder why? no one can access except the admin
6. difference between GET and POST methods
7. Include multiple files: include, include_once, require, require_once
8. what is a sticky form?
I have answered the first 4 subparts as there are a total of 8 parts of the question.
1. How to connect to Database: connecting string, query string mysqli_connect(), mysqli_query()
<?php
$conn =
mysqli_connect("localhost","username","password","name_of_database");
if(mysqli_connect_error())
{
echo "Error in connection";
}
mysqli_query($conn,"SQL_query"),
// mysqli_query($conn,"SELECT * FROM employee")
mysqli_close($conn);
?>
2. mysqli_fatch_array() - records returned, with while loop
<?php
$conn =
mysqli_connect("localhost","username","password","name_of_database");
if(mysqli_connect_error())
{
echo "Error in connection";
}
$data = mysqli_query($conn,"SELECT * from table_name");
while($rw = mysqli_fetch_assoc($data));
{
$col_1 = $rw['col_1'];
$col_2 = $rw['col_2'];
$col_n = $rw['col_n'];
echo $col_1 +" "+$col_2+" "+$col_n+<br>;
}
?>
3. form and name of variables that can be retrieved in PHP file.=> $_POST, $_GET
$_POST: Post method is used to send data to the database. It is more secure and has no limitations like the character limit or the file type that has to be stored in the database. In the case of the post method, the data is stored in an associative array and can information can be accessed using the same.
$_GET: It is used to retrieve the data from the database and is less secure as compared to post as the data gets displayed in the form of a string on the server log. It is limited to only 1024 characters and cannot be used to send images.
;" src= "https://media.HomeworkLibcdn.com/media/762/762cec2b-93c1-4c6a-a09c-2d1635e42776/php72QIAu.png" />
4. all the variables that a PHP file can access: _GET, _POST, SEVER, ... global variables with respect to the get and post methods in the form.
Global variables of PHP are :
PHP Review For the Programming part: 1. How to connect to Database: connecting string, query string...
PHP - Use of classes This is a further development of the previous task, the participant registration. You must use the following Participant class. <?php class Deltaker { private $etterNavn; private $forNavn; private $fAar; function __construct(string $fornavn, string $etternavn, string $aar) { $this->forNavn = $fornavn; $this->etterNavn = $etternavn; $this->fAar = $aar; } function hentEtterNavn() : string { return $this->etterNavn; } function hentForNavn() : string { return $this->forNavn; } function hentFAar() : string{ return $this->fAar; } //Setters function settForNavn(string $fornavn) {...
How can I print the Database table in PHP please ? here I have form for name and email, also I have php code that allow user to add his name and email to my database, all I need to print my final database when the user click on submit. <form action="" method="post"> <label>Name :</label> <input type="text" name="name" required="required" placeholder="Please Enter Name"/><br /><br /> <label>Email :</label> <input type="email" name="email" required="required" /><br/><br /> <input type="submit" value=" Submit " name="submit"/><br /> </form>...
<html> <!--This is the form for an instructor to upload a file having the grade of students in a class--> <body> <h2>Upload Student Grade</h2> <form action="1.php" method="POST" enctype="multipart/form-data"> Instructor's First Name:<input type="text" name="first"><br><br> Instructor's Last Name: <input type="text" name="last"><br><br> Instructor's Department Name:<input type="text" name="department"><br><br> Upload student grade: <input type="file" name="image" /><br><br> <input type="submit"/> </form> </body> </html> //***************************************************Q1**************************************************************************** /*(((( Q1)))). (18 points) Add the code below that * uploads the file containing the students'...
PHP Programming In this project, you will create a Web page that allows visitors to your site to sign a guest book that is saved to a database. Create a new document in your text editor and type the <!DOCTYPE> declaration, <html> element, document head, and <body> element. Use the strict DTD and “Guest Book” as the content of the <title> element. Add the following text and elements to the document body: <h2>Enter your name to sign our guest book</h2>...
Really need help with this. This is for my Advanced Java Programming Class. If anyone is an expert in Java I would very much appreciate the help. I will provide the code I was told to open. Exercise 13-3 Use JPA to work with the library checkout system In this exercise, you'll convert the application from the previous exercise to use JPA instead of JDBC to access the database. Review the project Start NetBeans and open the project named ch13_ex3_library that's...
I need help with this Mammal: public class Mammal extends Pet{ String Vaccination=""; public Mammal(String name, String parent, String species, String birthday, String Vaccination) { //Accessing the super class Constructor and setting the variables. super(name,parent,species, birthday); this.Vaccination=Vaccination; } // end Mammal public String getVaccination() { return Vaccination; } // end getVaccination public void setVaccination(String Vaccination) { this.Vaccination = Vaccination; } // end setVaccination @Override public String toString() { return super.toString()+". This Mammal requires following vaccinations "+ Vaccination; } // end...
Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...
#include <iostream> #include <iomanip> #include <vector> using namespace std; Part 1. [30 points] In this part, your program loads a vending machine serving cold drinks. You start with many foods, some are drinks. Your code loads a vending machine from foods, or, it uses water as a default drink. Create class Drink, make an array of drinks, load it and display it. Part 1 steps: [5 points] Create a class called Drink that contains information about a single drink. Provide...