0% found this document useful (0 votes)
29 views4 pages

Tabelarezervari PHP

The document contains PHP code to create a database table called "Rezervari" with fields for reservation ID, room ID, date, user name, and number of seats. It also contains a form to submit reservation data to a PHP file for insertion into the database table. The PHP file validates and sanitizes the form input before inserting a new record into the "Rezervari" table. Additionally, there is code to display the submitted form values.

Uploaded by

Marian Pîrjol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views4 pages

Tabelarezervari PHP

The document contains PHP code to create a database table called "Rezervari" with fields for reservation ID, room ID, date, user name, and number of seats. It also contains a form to submit reservation data to a PHP file for insertion into the database table. The PHP file validates and sanitizes the form input before inserting a new record into the "Rezervari" table. Additionally, there is code to display the submitted form values.

Uploaded by

Marian Pîrjol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Tabelarezervari.

php

<?php

require 'connection.php';

?>

<?php

$sql = "CREATE TABLE Rezervari (

idRezervare INT(5) AUTO_INCREMENT PRIMARY KEY,

idSala INT(5) NOT NULL,

data DATE(6),

numeUser VARCHAR(30),

nrLocuri INT(10)

)";

if ($sql) {

echo "TabelulRezervari a fostcreat cu succes ";

} else {

echo "Tabelul nu a fostcreat: " . $conn->error;

$conn->close();

?>

Formscriptrezervari.php

<?php

require 'connection.php';

?>

<?php
if(isset($_POST['Rezervare'])) {

$idSala = $_POST['idSala'];

$data = $_POST['data'];

$numeUser = $_POST['numeUser'];

$nrLocuri=$_POST['nrLocuri'];

$sql = $con->query("INSERT INTO Rezervare ( idSala, data, numeUser, nrLocuri)


values('{$idSala}','{$data}','{$numeUser}','{$nrLocuri}')");

?>

<html>

<head>

<titlle></titlle>

</head>

<body>

<form action="" method="post" name="Rezervari" id="Rezervari">

<input name="idSala" type="number" id="idSala"


placeholder="idSala">

<input name="data" type="date" id="data" placeholder="data">

<input name="numeUser" type="text" id="numeUser"


placeholder="numeUser">

<input name="Rezerva" type="submit" id="Rezerva" value="Rezerva">

</form>

</body>

</html>
Exercitiul 5
<!DOCTYPE HTML>

<html>

<head>

</head>

<body>

<?php

// define variables and set to empty values

$idRezervare = $idSala = $data = $numeUser = $nrLocuri = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {

$idRezervare = test_input($_POST["idRezervare"]);

$idSala = test_input($_POST["idSala"]);

$data = test_input($_POST["data "]);

$numeUser = test_input($_POST["numeUser"]);

$nrLocuri = test_input($_POST["nrLocuri"]);

function test_input($data) {

$data = trim($data);

$data = stripslashes($data);

$data = htmlspecialchars($data);

return $data;

?>

<h2> Form Lista </h2>

<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">


idRezervare : <textarea type="text" name="idRezervare" rows="2" cols="20"></textarea>

<br><br>

idSala : <input type="text" name="idSala">

<br><br>

data : <input type="text" name="data"

<br><br>

numeUser : <input type="text" name="numeUser"

<br><br>

nrLocuri : <input type="text" name="nrLocuri"

<br><br>

<input type="submit" name="submit" value="Submit">

</form>

<?php

echo "<h2> Lista :</h2>";

echo $idRezervare;

echo "<br>";

echo $idSala;

echo "<br>";

echo $data;

echo "<br>";

echo $numeUser;

echo "<br>";

echo $nrLocuri;

?>

</body>

</html>

You might also like