Jump to content

Learning PHP, Java Dev with a headache.


Go to solution Solved by Barand,

Recommended Posts

i Have this Form 

 

<form action="action_page.php" method="POST"> <div class="form-group"> <label for="email">Email address:</label> <input type="email" class="form-control" id="email"> </div> <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd"> </div> <div class="checkbox"> <label><input type="checkbox"> Remember me</label> </div> <button type="submit" class="btn btn-default">Submit</button> </form>

 

And im trying to pass the information into a USER class and print out the result in a action_page.php.

 

<?php class User {

private $password;

private $emailAddress;

function __construct() {

$this->emailAddress = isset($_POST['email']) ? $_POST['email'] : null;

$this->password = isset($_POST['pwd']) ? $_POST['pwd'] : null; }

function start() { if (empty($this->password) || empty($this->emailAddress)) {

throw new Exception("Empty Post not allowed");

} else

{ echo " Registration Done";

}

}

}

 

$register = new User(); if(!empty($_POST)) { $register->start(); }

 

Then in my action page i try to refernence the Object with

 

?php include "User.php";

$user = new User(); try { $user->start(); }

catch (Exception $e) { echo "Cannot Find account"; }

 

but it never can do it ? 

Anyone any ideas ??

 

Link to comment
https://forums.phpfreaks.com/topic/312203-learning-php-java-dev-with-a-headache/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.