cant use post or get action to get data from html page
Posted: Mon Mar 05, 2012 11:51 am
i have a very basic set up here a html page with some php on my server with two input boxes to take in a email and password and a submit button when i try and submit the data i dont seem to be getting anything back when using "get" or "post" in the html form action. i have tryed method ="<?=$_SERVER['PHP_SELF'];?>" as the method and method ="" and neither work. here is my code for the index. i basically need the data inputed by the user to do anything with the class so far i havent been able to grab the data entered at all.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<form action="get" method="">
<label for="email">enter email</label>
<input type="text" id="email" name="email" /><br />
<label for="password">enter password</label>
<input type="text" id="password" name="password"/><br />
<input type="submit" value="submitbutton" name="submit" />
</form>
<?php
include("userdetails.php"); //this is a class
if(isset($_GET['submit']))
{
session_start();
$user = new userdetails();
$name = $user->getname();
echo $name;
}
?>
</body>
</html>
here is some of my userdetails.php class, the parts that im using so far, obviously i hope to do a lot more with it.
<?php
class userdetails {
private $email;
private $password;
public function __construct() {
$this->email = $_GET['email'];
$this->password =$_GET['password'];
}
public function getname()
{
if(isset($this->email))
{
return $this->email;
}
else
{
return "notset";
}
}
}
?>
anyway thanks for all the help you can give me ive been stuck on this for a while now if i cant get this im not going to pass this project unfortunately . its doing my head in!
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<form action="get" method="">
<label for="email">enter email</label>
<input type="text" id="email" name="email" /><br />
<label for="password">enter password</label>
<input type="text" id="password" name="password"/><br />
<input type="submit" value="submitbutton" name="submit" />
</form>
<?php
include("userdetails.php"); //this is a class
if(isset($_GET['submit']))
{
session_start();
$user = new userdetails();
$name = $user->getname();
echo $name;
}
?>
</body>
</html>
here is some of my userdetails.php class, the parts that im using so far, obviously i hope to do a lot more with it.
<?php
class userdetails {
private $email;
private $password;
public function __construct() {
$this->email = $_GET['email'];
$this->password =$_GET['password'];
}
public function getname()
{
if(isset($this->email))
{
return $this->email;
}
else
{
return "notset";
}
}
}
?>
anyway thanks for all the help you can give me ive been stuck on this for a while now if i cant get this im not going to pass this project unfortunately . its doing my head in!