Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Class cars
- <?php
- class Car{
- private $mark;
- private $model;
- private $year;
- private $engine;
- public function __construct($mk,$models,$years,$theengen) {
- $this->mark=$mk;
- $this->model=$models;
- $this->year=$years;
- $this->engine=$theengen;
- }
- public function getMark(){
- return $this->mark;
- }
- public function getModel(){
- return $this->model;
- }
- public function getYear(){
- return $this->year;
- }
- public function getEngen(){
- return $this->engine;
- }
- public function printCars(){
- echo "Your car is {$this->mark} model {$this->model} production yera "
- . "{$this->year} with size on the engien {$this->engine}cc".'<br>';
- }
- }
- if($hidden == 1){
- $newcar = new Car($mark,$model,$year,$engine);
- $newcar->printCars();
- }
- ?>
- //Form for cars___________________________________________________________________|
- <form action="formForCars.php" method="post">
- <div>Input your's car...</div>
- <input type="hidden" name="hidden" value="1">
- Mark:<input type="text" name="mark">
- Model:<input type="text" name="model">
- Year:<input type="text" name="year">
- Engine:<input type="text" name="engine">
- <input type="submit" value="Submit">
- </form>
- <?php
- if(isset($_POST['mark'])
- || isset($_POST['model'])
- || isset($_POST['year'])
- || isset($_POST['engine'])
- || isset($_POST['hidden'])){
- $mark = trim($_POST['mark']);
- $model = trim($_POST['model']);
- $year = trim($_POST['year']);
- $engine = trim($_POST['engine']);
- $hidden = trim($_POST['hidden']);
- if(strlen($mark)>=2 && strlen($mark)>=2 && strlen($mark)>=2 && strlen($mark)>=2 ){
- include 'cars.php';
- }
- else {
- echo '<div style="color:red">'.'FAILURE!'.'</div>';
- }
- }
- ?>
- //User calss__________________________|
- <?php
- class User{
- protected $firstname;
- protected $lastyname;
- protected $age;
- protected $profilpic;
- protected $sex;
- protected $password;
- protected $squestion;
- protected $sanswer;
- protected $email;
- function __construct($firstname, $lastyname, $age, $profilpic, $sex, $password, $squestion, $sanswer, $email) {
- $this->firstname = $firstname;
- $this->lastyname = $lastyname;
- $this->age = $age;
- $this->profilpic = $profilpic;
- $this->sex = $sex;
- $this->password = $password;
- $this->squestion = $squestion;
- $this->sanswer = $sanswer;
- $this->email = $email;
- }
- public function printForm(){
- $printData = "Name:{$this->firstname}:LastName:{$this->lastyname}:"
- . "Age:{$this->age}:Picture:{$this->profilpic}:Sex:{$this->sex}:"
- . "Password:{$this->password}:Question:{$this->squestion}:"
- . "Answer:{$this->sanswer}:Email:{$this->email}:";
- file_put_contents('userdata.txt', $printData."\n",FILE_APPEND);
- }
- }
- class Workman extends User{
- protected $profession;
- protected $payment;
- function __construct($profession, $payment) {
- $this->profession = $profession;
- $this->payment = $payment;
- }
- public function printForm(){
- $printData = "Profession:{$this->profession}:"
- . "Payment{$this->payment}:";
- file_put_contents('userdata.txt', $printData."\n",FILE_APPEND);
- }
- }
- if($hidden==1){
- $file=1;
- $users=new User($firstname,$lastname,$age,$file,$sex,$pass,$question,$answer,$email);
- $extend=new Workman($pro, $pay);
- $users->printForm();
- $extend->printForm();
- }
- ?>
- //Form for user_________________________|
- <form action="formForUser.php" method="post" accept-charset=""enctype="multipart/form-data">
- <input type="hidden" name="submitForm" value="1">
- First name:<input type="text" name="firstname"></br>
- Last name:<input type="text" name="lastname"></br>
- Age:<input type="text" name="age"></br>
- Password:<input type="password" name="pass"></br>
- Security question:<input type="text" name="question"></br>
- Security answer:<input type="text" name="answer"></br>
- Email:<input type="email" name="email"></br>
- sex:
- male:<input type="radio" name="sex" value="male" class="male">
- female:<input type="radio" name="sex" value="female" class="female"></br>
- Picture:<input type="file" name="file" id="file"></br>
- Profession:<input type="text" name="pro"></br>
- Payment:<input type="text" name="pay"></br>
- <input type="submit" value="Submit">
- </form>
- <?php
- if(isset($_POST['firstname'])
- || isset($_POST['lastname'])
- || isset($_POST['age'])
- || isset($_POST['pass'])
- || isset($_POST['question'])
- || isset($_POST['answer'])
- || isset($_POST['email'])
- || isset($_POST['submitForm'])
- || isset($_POST['sex'])
- || isset($_FILES["file"]["error"])
- || isset($_POST['pro'])
- || isset($_POST['pay'])){
- $firstname = trim($_POST['firstname']);
- $lastname = trim($_POST['lastname']);
- $age = trim($_POST['age']);
- $pass = trim($_POST['pass']);
- $question = trim($_POST['question']);
- $answer = trim($_POST['answer']);
- $email = trim($_POST['email']);
- $sex = trim($_POST['sex']);
- $hidden = trim($_POST['submitForm']);
- $file = trim($_FILES["file"]["error"]);
- $pro = trim($_POST['pro']);
- $pay = trim($_POST['pay']);
- include 'userClass.php';
- if ($_FILES["file"]["error"] > 0)
- {
- echo "Error: " . $_FILES["file"]["error"] . "<br>";
- }
- else {
- echo "Upload: " . $_FILES["file"]["name"] . "<br>";
- echo "Type: " . $_FILES["file"]["type"] . "<br>";
- echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
- echo "Stored in: " . $_FILES["file"]["tmp_name"];
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment