Hi i wounder how i can echo or print in i function ???
i made this code with functons and it do not work its just an exampel of what i wount,,, and i wounder how i can switch prints .... take the info(); for exampel there i wount it to print the first time if i submit it shoulde change text at the same place to something else how do i do it!
<?php
$username = $_POST["username"];
$set = $_POST["set"];
function emailsyntax_is_valid($email) {
$to_work_out = explode("@", $email);
if (!isset($to_work_out[0])) return FALSE;
if (!isset($to_work_out[1])) return FALSE;
$pattern_local = '^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$';
$pattern_domain = '^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$';
$match_local = eregi($pattern_local, $to_work_out[0]);
$match_domain = eregi($pattern_domain, $to_work_out[1]);
if ($match_local && $match_domain) {
return TRUE;
}
return FALSE;
}
if ($set=="set") {
$username_control = 1;
$username2_control = 1;
$username3_control = 1;
$main_control = 1;
if($username == ""){
$empty_username = "Ooops! - You forgot to enter your username.";
$username_control = 0;
$main_control = 0;
}
elseif(strlen($username) < 4){
$empty_username = "Ooops! - Your username should be at least 4 letters long.";
$username2_control = 0;
$main_control = 0;
}
elseif(strlen($username) > 20){
$empty_username = "Ooops! - Your username can't be larger than 20 letters.";
$username3_control = 0;
$main_control = 0;
}
elseif($main_control = 1){
$str = $username;
$str = strtolower($str);
}
}
if($main_control == 1) {
}
?>
<?PHP
function info() {
}
print "Please enter your usernamen in the blank field <br>
below then after press get password button to <br>
get your password.<br>";
function validuser() {
}
print "Welcome $_POST[username].in some seconds you <br>
will recive a email with your password in it.<br>";
function invaliduser() {
}
print "Sorry, incorrect username ( $_POST[username] ).<br>
if not a member <a href=\"register.php\">click here to register.</a>";
?>
info(); // an exampel
<br>
<form action="2.php" method="post" name="hej">
Youe Username Here:<br><br>
<input type="text" name="username" size="15" class="inputSidebar" value="<?php
if($username_control != 0){ echo $_POST['username'];}
elseif(username2_control !=0){ echo $_POST['username'];}
elseif(username3_control !=0){ echo $_POST['username'];}
else{ echo ''; } ?>">
<?php echo $empty_username; ?>    
<input class="button" type="submit" name="submit" value="Get password">
<?php echo $_POST['username']; ?>
<input type="hidden" name="set" value="set">
</form>
<body>
</body>
</html>