[php]errors na het herschrijven/toevoegen van superglobals

Pagina: 1
Acties:
  • 52 views sinds 30-01-2008

  • X-Rey
  • Registratie: April 2002
  • Laatst online: 27-07 15:47
Op een duitse site heb ik een inschrijfsysteem voor een lan party gevonden...
Helaas was de nog geschreven in de tijd dat er geen superglobals werden
gebruikt dus heb ik dit aangepast met behulp van iemand anders, maar ik krijg
nog steeds een error...

NB:
-bestandsnamen zijn nog niet veranderd
-sommige dingen zijn nog in het duits...

de errors
Notice: Undefined index: status in c:\server\sites\lan\mod.guests.php on line 101

Notice: Undefined index: status in c:\server\sites\lan\mod.guests.php on line 117

Notice: Undefined index: status in c:\server\sites\lan\mod.guests.php on line 107

de regels waar de errors in zitten:

101: if ($row["status"] == $i)
107: if ($row["status"] < 3)
117: if ($row["status"] != $i) {

alle php-bestanden

mod.guests.php
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?
/* mod.guests.php          version 19/jan/2002 */
/* copyright © 2001 Y0Gi <webmaster@nwsnet.de> */

/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/

class guests
{
  /* mysql data */
  var $db_host  = "localhost";
  var $db_user  = "";
  var $db_pass  = "";
  var $db_name  = "lan";
  var $db_tbl   = "guests";


  /* will be filled in constructor */
  var $fast_mode;
  var $color_line;
  var $status;
  var $url;


  /* constructor - executed on object creation */
  function guests()
  {
    // set to 1 to skip confirmation on status change
    $this->fast_mode = 0;

    // every second row will be filled with this color
    $this->color_line = "#e4c494";

    // status labels and colors
    $this->status[0]["label"] = "angemeldet";
    $this->status[0]["color"] = "#aa000";
    $this->status[1]["label"] = "bezahlt";
    $this->status[1]["color"] = "#006600";
    $this->status[2]["label"] = "platz reserviert";
    $this->status[2]["color"] = "#000088";
    $this->status[3]["label"] = "eingecheckt";
    $this->status[3]["color"] = "#444444";

    // links    
    $this->url["add"]     = "mod.guests-example-add.php";
    $this->url["list"]    = "mod.guests-example-list.php";
    $this->url["checkin"] = "mod.guests-example-checkin.php";
    $this->url["admin"]   = "mod.guests-example-admin.php";

    // connect to mysql and select database
    $link = mysql_connect($this->db_host, $this->db_user, $this->db_pass);
    mysql_select_db($this->db_name, $link);
  }


  /* general list */
  function show_list($type="")
  {
    $result = mysql_query("SELECT * FROM " . $this->db_tbl . " ORDER BY id");

    if ($type == "admin")
      echo "<form action=\"" . $_SERVER["SCRIPT_NAME"] . "\" method=\"post\">\n";
    echo "<table cellspacing=0 cellpadding=2 border=0>\n";
    echo "  <tr>\n";
    echo "    <td><b>ID</b></td>\n";
    echo "    <td width=140><b>Nick</b></td>\n";
    echo "    <td width=180><b>Clan</b></td>\n";
    echo "    <td width=100><b>Status</b></td>\n";
    if ($type == "checkin")
      echo "    <td width=80>&nbsp;</td>\n";
    if ($type == "admin")
      echo "    <td colspan=4><b>&auml;ndern in</b></td>\n";
    echo "  </tr>\n";

    $line = 1;
    while ($row = mysql_fetch_assoc($result)) {
      if ($line % 2 == 1)
        echo "  <tr bgcolor=" . $this->color_line . ">\n";
      else
        echo "  <tr>\n";

      echo "    <td>" . $row["id"] . "</td>\n";
      echo "    <td>" . $row["nick"] . "</td>\n";
      echo "    <td>" . $row["clan"] . "</td>\n";

      for ($i = 0; $i < 4; $i++)
        if ($row['status'] == $i)
          echo "    <td><font color=" . $this->status[$i]["color"] . ">" . $this->status[$i]["label"] . "</font></td>\n";

      // additional field for check-in list
      if ($type == "checkin") {
        echo "    <td><b>";
        if ($row["status"] < 3)
          // needs two &'s to show one... mail me if you can tell me why... change if necessary
          echo "<a href=\"" . $this->url["checkin"] . "?id=" . $row["id"] . "&&status=3" . "\">einchecken</a>";
        echo "&nbsp;</b></td>\n";
      }

      // additional field for admin list
      if ($type == "admin") {
        for ($i = 0; $i < 4; $i++) {
          echo "    <td><b>\n";
          if ($row["status"] != $i) {
            // needs two &'s to show one... mail me if you can tell me why... change if necessary
            $link = $this->url["admin"] . "?id=" . $row["id"] . "&&status=" . $i;
            echo "<a href=\"" . $link . "\"><font color=" . $this->status[$i]["color"] . ">" . substr($this->status[$i]["label"], 0, 1) . "</font></a>\n";
          }
          else
            echo "&middot;";
          echo "&nbsp;</b></td>\n";
        }
      }

      echo "  </tr>\n";
      $line++;
    }
    echo "</table>\n";
    echo "<br><br>" . $this->copyright . "<br>\n";
    if ($type == "admin")
      echo "</form>\n";
  }


  /* set status */
  function set_status($id, $status, $type)
  {
    $result = mysql_query("UPDATE " . $this->db_tbl . " SET status=" . $status . " WHERE id=" . $id);
/*
    $result = mysql_query("SELECT * FROM " . $this->db_tbl . " WHERE id=" . $id);
    while ($row = mysql_fetch_assoc($result))
      echo "<b>" . $row["nick"] . "</b> hat nun den Status <b><font color=" . $this->status[$row["status"]]["color"] . ">" . $this->status[$row["status"]]["label"] . "</font></b>.<br>\n";
    echo "<br><a href=\"" . $this->url[$type] . "\">Liste anzeigen</a><br>\n";
    if ($this->fast_mode == 1)
      echo "<script language=\"javascript\"><!-- document.location.href='" . $this->url[$type] . "'; --></script>\n";
*/

    if ($this->fast_mode == 0) {
      $result = mysql_query("SELECT * FROM " . $this->db_tbl . " WHERE id=" . $id);
      while ($row = mysql_fetch_assoc($result))
        echo "<b>" . $row["nick"] . "</b> hat nun den Status <b><font color=" . $this->status[$row["status"]]["color"] . ">" . $this->status[$row["status"]]["label"] . "</font></b>.<br>\n";
      echo "<br><a href=\"" . $this->url[$type] . "\">Liste anzeigen</a><br>\n";
    }
    else
      $this->show_list($type);

/*
    if ($this->fast_mode == 0) {
      $result = mysql_query("SELECT * FROM " . $this->db_tbl . " WHERE id=" . $id);
      while ($row = mysql_fetch_assoc($result))
        echo "<b>" . $row["nick"] . "</b> hat nun den Status <b><font color=" . $this->status[$row["status"]]["color"] . ">" . $this->status[$row["status"]]["label"] . "</font></b>.<br>\n";
      echo "<br><a href=\"" . $this->url[$type] . "\">Liste anzeigen</a><br>\n";
    }
    else {
      header("Location: " . $this->url[$type]);
      exit;
    }
*/
  }


  /* number of guests */
  function num($status=9)
  {
    $query = "SELECT * FROM " . $this->db_tbl;
    if ($status >= 0 && $status <= 3)
      $query .= " WHERE status=" . $status;
    $result = mysql_query($query);
    return mysql_num_rows($result);
  }


  /* add form */
  function add_form() {
?>

<form action="<?= $this->url["add"]; ?>" method="post" ?>" method="post" ?>" method="post">
<br><table cellspacing=0 cellpadding=2 border=0>
  <tr>
    <td><u>Name</u>:</td>
    <td><input type=text name="name" size=16 maxlength=20></td>
  </tr>
  <tr>
    <td><u>EMail</u>:</td>
    <td><input type=text name="email" size=16 maxlength=40></td>
  </tr>
  <tr>
    <td><u>Nick</u>:</td>
    <td><input type=text name="nick" size=16 maxlength=20></td>
  </tr>
  <tr>
    <td><u>Clan</u>:</td>
    <td><input type=text name="clan" size=16 maxlength=40></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align=center><br><input type=submit value="Anmelden"></td>
  </tr>
</table>
<br><?= $this->copyright; ?>
</form>

<?
  }


  /* add process */
  function add_res($name, $email, $nick, $clan) {
    $result = mysql_query("INSERT INTO " . $this->db_tbl . " (name, email, nick, clan, time, ip) VALUES ('$name', '$email', '$nick', '$clan', '" . date("d_m_Y H:i") . "', '" . getenv("REMOTE_ADDR") . "')");
    echo "Sch&ouml;n, dass du dich angemeldet hast, <b>" . $nick . "</b>!<br>\n";
    echo "Du wurdest in die G&auml;steliste aufgenommen.<br>\n";
    echo "<br><a href=\"" . $this->url["list"] . "\">G&auml;steliste anzeigen</a><br>\n";
  }


  /* please do not remove this copyright - this is gpl software (and it was hard work, too...) */
  var $copyright = '<span style="font-size: 8pt">copyright &copy; 2001 jochen kupperschmidt aka Y0Gi</span>';
}
?>


mod.guests-example-add.php: word gebruikt om je mee inteschrijven
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<html>
<body>
<div align=center>


<?
require("mod.guests.php");
$guests = new guests();

if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['nick']) ) 
  $guests->add_res($_POST['name'], $_POST['email'], $_POST['nick'], $_POST['clan']); 
else
  $guests->add_form();
?>


</div>
</body>
</html>


mod.guests-example-admin.php: word gebruikt voor de admin mogelijk heden (betaald enzo)
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?
/* set this to prevent this page from being cached */
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0
?>

<html>
<head>
  <style type="text/css">
    body, th, td         { font-family: arial; font-size: 8pt; }
    a:link, a:visited    { color: #000000; text-decoration: none; }
    a:active, a:hover    { color: #000000; text-decoration: underline; }
  </style>
</head>
<body bgcolor=#d4b488 text=#000000>
<div align=center>


<br>
<?
require("mod.guests.php");
$guests = new guests();

if (isset($id) && isset($status))
  $guests->set_status($_POST['id'], $_POST['status'], "admin");
else
  $guests->show_list("admin");
?>


</div>
</body>
</html>


mod.guests-example-checkin.php: word gebruikt om te zeggen dat je op de lan party bent
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?
/* set this to prevent this page from being cached */
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0
?>

<html>
<head>
  <style type="text/css">
    body, th, td          { font-family: arial; font-size: 8pt; }
    a:link, a:visited     { color: #000000; text-decoration: none; }
    a:active, a:hover     { color: #000000; text-decoration: underline; }
  </style>
</head>
<body bgcolor=#d4b488 text=#000000>
<div align=center>


<br>
<?
require("mod.guests.php");
$guests = new guests();

if (isset($id) && isset($status))
  $guests->set_status($_POST['id'], $_POST['status'], "checkin");
else
  $guests->show_list("checkin");
?>


</div>
</body>
</html>


mod.guests-example-list.php: word gebruikt om te zijn wie zich allemaal hebben aangemeld

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?
/* set this to prevent this page from being cached */
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0
?>

<html>
<head>
  <style type="text/css">
    body, th, td         { font-family: arial; font-size: 8pt; }
  </style>
</head>
<body bgcolor=#d4b488 text=#000000>
<div align=center>


<br>
<?
require("mod.guests.php");
$guests = new guests();

$guests->show_list();
?>


</div>
</body>
</html>


mod.guests-example-status.php: word gebruikt om de status van je aanmeldingen te zien
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?
/* set this to prevent this page from being cached */
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0
?>

<html>
<body>
<div align=center>


<?
require("mod.guests.php");
$guests = new guests();
?>

<?= $guests->num(); ?> insgesamt<br>
<?= $guests->num(0); ?> angemeldet<br>
<?= $guests->num(1); ?> bezahlt<br>
<?= $guests->num(2); ?> platz reserviert<br>
<?= $guests->num(3); ?> eingecheckt<br>


</div>
</body>
</html>


Download hier de OUDE code
wat is hier fout aan? :?

[ Voor 23% gewijzigd door X-Rey op 23-10-2003 14:35 ]


  • Janoz
  • Registratie: Oktober 2000
  • Laatst online: 17-08 23:56

Janoz

Moderator Devschuur®

!litemod

Het lijkt me niet nodig om tig pagina's aan sourcecode te posten waneer je zo'n duidelijke foutmelding krijgt. Het lijkt me handiger om gewoon de relevante gegevens te posten. Heb je trouwens wel een kolom status in je db?

Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'


  • X-Rey
  • Registratie: April 2002
  • Laatst online: 27-07 15:47
de sql code:

code:
1
2
3
4
5
6
7
8
9
10
11
CREATE TABLE guests (
  id int(4) NOT NULL auto_increment,
  name varchar(64) NOT NULL default '',
  email varchar(64) NOT NULL default '',
  nick varchar(32) NOT NULL default '',
  clan varchar(32) NOT NULL default ' - clanlos -',
  status int(1) unsigned zerofill NOT NULL default '0',
  time varchar(16) NOT NULL default '',
  ip varchar(15) NOT NULL default '',
  PRIMARY KEY  (id)
);

[ Voor 11% gewijzigd door X-Rey op 23-10-2003 14:44 ]


  • Janoz
  • Registratie: Oktober 2000
  • Laatst online: 17-08 23:56

Janoz

Moderator Devschuur®

!litemod

Ik denk niet dat mensen deze berg pagina's door gaan nemen om het probleem voor jou/jullie op te lossen. Als je nu alleen relevante gegevens had geplaatst alla, maar dit is meer een 'dump de foutmelding, dump de source en laat mensen het maar oplossen'.

Lees anders ook ff de faq van dit forum door waarin wordt aangegeven wat wij van de topics hier verwachten.

Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'


  • curry684
  • Registratie: Juni 2000
  • Laatst online: 13-08 16:46

curry684

left part of the evil twins

Op een duitse site heb ik een inschrijfsysteem voor een lan party gevonden...
Helaas was de nog geschreven in de tijd dat er geen superglobals werden
gebruikt dus heb ik dit aangepast met behulp van iemand anders, maar ik krijg
nog steeds een error...
Ergo je hebt het zelf geschreven noch aangepast. Daar is Programming & Webscripting niet voor bedoeld, dit is een forum voor discussies over zelf geprogrammeerde software. Voor andermans' software is het adagium: mail de maker :)

Punt is dat je er zelf de ballen van snapt en niets van leert, het gaat je puur erom om iets werkend te krijgen en dan een stuk software te hebben. Daar zijn genoeg professionals tegen betaling voor beschikbaar, maar GoT is geen gratis variant daarop.

Professionele website nodig?


Dit topic is gesloten.