Hendz 0 Posted February 23 Share Posted February 23 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 ?? Quote Link to post Share on other sites
gw1500se 62 Posted February 23 Share Posted February 23 Use 'name' not 'id' on your input fields. Quote Link to post Share on other sites
Solution Barand 1,632 Posted February 23 Solution Share Posted February 23 You will actually need both the id and the name The label/for attributes use the id, POST variables use the name. Quote Link to post Share on other sites
Hendz 0 Posted February 23 Author Share Posted February 23 Thanks i added the name + id and it fixed my proble. enjoying php pretty similar to Java but just getting the hang of OOP and PDO a learning experience lol Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.