kurde pomóżcie bo napisałem skrypt rejestracji ale mam błąd:
Notice: Undefined variable: action in C:\Program Files\Apache Group\Apache2\htdocs\2\register2.php on line 175
linijka 175 odpowiada tej linijce co jest w kodzie niżej... proszę pomóżcie
kod:
<?php
$default_dbname = 'sample_db';
$user_tablename = 'user';
$MYSQL_ERRNO = '';
$MYSQL_ERROR = '';
function sql_error() {
global $MYSQL_ERRNO, $MYSQL_ERROR;
if(empty($MYSQL_ERROR)) { }
return "$$MYSQL_ERRNO: $MYSQL_ERROR";
}
function html_header() {
?>
<HTML>
<HEAD><title>Rejestracja</title></HEAD>
<body>
<?php
}
function html_footer() {
?>
</body>
</HTML>
<?php
}
function in_use($userid) {
$query = "SELECT userid FROM $usertable_name WHERE userid = '$userid'";
else return 1;
}
function register_form() {
global $userid, $username, $usercountry, $useremail, $userprofile, $country_array;
?>
<center>Rejestracja</center>
<form method="POST" action="
<?php echo $PHP_SELF ?>">
<input type="hidden" name="action" value="register">
<div align="center"><center><table border="1" width="90%">
<tr>
<th width="30%" nowrap>Login</th>
<td width="70%"><input type="TEXT" name="userid" value="
<?php echo $userid ?>" size="8" maxlength="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Hasło</th>
<td width="70%"><input type="password" name="userpassword" size="15"></td>
</tr>
<tr>
<th width="30%" nowrap>Powtórz Hasło</th>
<td width="70%"><input type="password" name="userpassword2" size="15"></td>
</tr>
<tr>
<th width="30%" nowrap>Imię i Nazwisko</th>
<td width="70%"><input type="TEXT" name="username" value="
<?php echo $username ?>" size="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Kraj</th>
<td width="70%"><input type="TEXT" name="username" value="
<?php echo $usercountry ?>" size="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Email</th>
<td width="70%"><input type="TEXT" name="useremail" size="20" value="
<?php echo $useremail ?>" ></td>
</tr>
<tr>
<th width="30%" nowrap>Opis Użytkownika</th>
<td width="70%"><textarea rows="5" cols="40" name="userprofile"></textarea></td>
</tr>
<tr>
<th width="30%" colspan="2" nowrap>
<input type="submit" value="Rejestruj">
<input type="reset" value="Wyczyść">
</th>
</tr>
</table>
</center>
</div>
</form>
<?php
}
function create_account() {
global $userid, $username, $userpassword, $userpassword2, $usercountry, $useremail, $userprofile; global $default_dbname, $user_tablename;
if(empty($userid)) error_message
("Podaj Login!"); if(empty($userpassword)) error_message
("Podaj Hasło!"); if(strlen($userpassword) < 4 ) error_message
("Hasło jest zbyt krótkie!"); if(empty($userpassword2)) error_message
("Powtórnie podaj Hasło!"); if(empty($username)) error_message
("Podaj imię i nazwisko!"); if(empty($useremail)) error_message
("Podaj adres email!"); if(empty($usercountry)) error_message
("Podaj Kraj!"); if(empty($userprofile)) $userprofile = "Brak opisu"; if($userpassword != $userpassword2) error_message("Wybrane i powtórzone hasła nie są identyczne!");
if(in_use($userid)) error_message("Nazwa Użytkownika $userid jest już zajęta. Wybierz inny login.");
$query = "INSERT INTO user VALUES(NULL, '$userid', password('$userpassword'), '$username', 'M', 'Brak Daty Urodzin', 'Brak Adresu', '$usercountry', '$useremail', '$userprofile', 'Brak danych o zaintereswoaniach', 'Brak danych o pseudonimie', 'Brak NR GG', 'curdate(), NULL)";
if(!$result) error_message(sql_error());
html_header();
?>
<CENTER>
<?php echo $username ?>, dziękujemy za zarejestrowanie się!</CENTER>
<div align="center"><center><table border="1" width="90%">
<tr>
<th width="30%" nowrap>Numer użytkownik</th>
<td width="70">
<?php echo $usernumber ?></td>
</tr>
<tr>
<th width="30%" nowrap>Wybrany identyfikator</th>
<td width="70">
<?php echo $userid ?></td>
</tr>
<tr>
<th width="30%" nowrap>Wybrane hasło</th>
<td width="70">
<?php echo $userpassword ?></td>
</tr>
<tr>
<th width="30%" nowrap>Imię i Nazwisko</th>
<td width="70">
<?php echo $username ?></td>
</tr>
<tr>
<th width="30%" nowrap>Kraj</th>
<td width="70">
<?php echo $usercountry ?></td>
</tr>
<tr>
<th width="30%" nowrap>Kraj</th>
<td width="70">
<?php echo $usercountry ?></td>
</tr>
<tr>
<th width="30%" nowrap>Email</th>
<td width="70">
<?php echo $useremail ?></td>
</tr>
<tr>
<th width="30%" nowrap>Opis</th>
</tr>
</table>
</center>
</div>
<?php
html_footer();
}
switch($action) {
case "register":
create_account();
break;
default:
html_header();
register_form();
html_footer();
break;
}
?>