jp504
30 Jan 2011, 02:16 PM
I need help getting my code to work. The php script is not working with the html form. I can't tell if i'm supposed to use javascript too. Could anyone please look at the code below and provide a solution to my problem.
HTML FORM:
<form action="practice.php" method="post">
<label id="lblFirstname" for="txtFirstname">Enter your First Name: </label>
<input type="text" id="txtFirstname" name="firstname" tabindex="1" />
<br />
<input type="submit" value="submit" id="btnSubmit" name="submit" tabindex="2" />
</form>
PHP CODE:
<?php
class practice {
public $firstname = $_POST['firstname'];
public function name() {
return( $firstname );
}
}
$obj = new practice();
$obj->name();
?>
HTML FORM:
<form action="practice.php" method="post">
<label id="lblFirstname" for="txtFirstname">Enter your First Name: </label>
<input type="text" id="txtFirstname" name="firstname" tabindex="1" />
<br />
<input type="submit" value="submit" id="btnSubmit" name="submit" tabindex="2" />
</form>
PHP CODE:
<?php
class practice {
public $firstname = $_POST['firstname'];
public function name() {
return( $firstname );
}
}
$obj = new practice();
$obj->name();
?>