In my index.php file, I have two sets of codes. One set of code relies heavily on php, and functions while the other set of code relies of only html. I'm trying to get the submit button to get the codes to go to the file register.php, but only the html codes are getting to the file register.php, while the php function codes just sits on the same page when you click the register button. Please help. Thanks.
Inside PHP file called functions.php I have 3 functions:
<?php
//****************************************************************
function echoForm($action){
echo "<method = 'post' action = '$action'>";
}
//****************************************************************
function echoField($type,$name,$maxlength,$text){
if($type == 'text'){
echo "$text</br><input type = 'text' name='$name' size = '15' maxlength = '$maxlength'/></br>";
}
else if($type == 'pass'){
echo "$text</br><input type = 'password' name = '$name' size = '15' maxlength = '$maxlength'/></br>";
}
else if($type == 'submit'){
echo "<input type = 'submit' name = '$name' value = '$text'/>";
}
}
//****************************************************************
function echoText($text){
echo "$text</br>";
}
?>
Inside PHP file called index.php I have my main codes:
<?php
include('functions.php');
echoForm('register.php');
echoField('text','username','20','Username');
echoField('pass','password','20','Password');
echoField('text','email','50','Email');
echoField('submit','submit','null','Register');
echoText('</form></br>');
?>
<html>
<body>
<form name = "form" method = "post" action = "register.php">
<input type = "text" name="username" size = "15" maxlength = "20" value=""/>
<input type = "password" name = "password" size = "15" maxlength = "20" value=""/>
<input type = "text" name = "email" size = "15" maxlength = "50" value=""/>
<input type = "submit" name = "submit" value = "Register"/>
</form>
</body>
</html>
echoForm().index.php, once using your strange helper methods and the second time more conventionally in HTML. Why is that?