I'm stuck trying to have PhP script post to next form. My script, addUser.php, checks flat DB file, users.php, against user input and returns if name is already taken. If not available it returns user to addUser.php, if available it sends user to reg.htm requiring user to complete registration.
The forms input text field, "user" is named in the addUser.php which is to post or pass the users input into the reg.htm forms "user" input box.
Everthing works fine except posting the avilable name user creates to the next forms "user" text field.
Have been struggling with this due to inexperience of PhP know -how.
Any help will be gratly appreciated..... this is my first php attempt.
Thanks in Advance,
<?php
session_start();
header("Cache-control: private");
if(@$_SESSION['user']) header("location: login.php");
elseif(@$_POST['user']){
$user = htmlspecialchars(strtolower($_POST["user"]));
$string = "\r\n". $user. "<del>".
$file = file("users.php") or die("Problem getting the user details flat-file [users.php]");
$totalLines = sizeof($file);
$line = 0;
$match = 0;
do{
if("//" != substr($file[$line], 0, 2)){
@list($NAME) = explode("<del>", $file[$line]);
if((strtolower($user) == strtolower($user))) $match = 1;
else $match = 0;
}
if($match) break;
$line++;
} while($line < $totalLines);
if($match){
?>
<script language = "javascript" type = "text/javascript">
<!-- // Go back
alert("NAME already taken, taking you back to choose another");
history.go(-1);
-->
</script>
<?php
}
else{
$fp = fopen("users.php", "a");
fwrite($fp, $string);
fclose($fp);
header("location: reg.htm#dwn");
echo "<$input type=\"text\" name=\"user\" value=\"".$_POST['user']."\">";
}
}
else{
?>
<form NAME="form1" method = "post" action = "<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="user" value="<?php echo $_POST['user'];?>" >
<input name="user" type="text" class="text" id="user">
<input type="button" value="submit">
-------------------------------------------------------------- end of addUser.php
-------------------- reg.htm PAGE --------------------
<form action="xxxx.com" method="post" name="visibleForm" target="_blank" onSubmit="return check(this);">
<input type="hidden" name="user" value="<?php echo $_POST['user'];?>" >
<input type="text" name="name">
<input type="text" name="organization">
<input type="text" name="address">
<input type="text" name="city">
<input type="text" name="state">
<input type="text" name="zip">
<input type="text" name="email">
<input type="text" name="phone">
<input type="text" name="user" value="?php echo $_POST['user'];?">
<input type="button" value="submit">