Variable wird nicht erkannt ?!

NetPerformance

Erfahrenes Mitglied
Hi ..

Die Variable $_id = $_GET['id']; ist bei der if($password == $_id) Abfrage unbekannt !
Was muss ich machen, damit die auch untern erkannt wird ?!

Beispiel: wenn der Link angeklickt wird, wird das untere Script aufgerufen !
http://www.URL.de/script.php?id=7t9ge8&guest=Pascal&user=aaron


Gruß
Aaron

Code:
<?php 

$_id = $_GET['id'];
$_guest = $_GET['guest'];
$_user  = $_GET['user'];

echo $_id; // <---  wird erkannt !

echo "<html> 
<head> 
<title></title> 
</head> 

<body bgcolor=#CCCCCC> 

<p>Hallo $_guest,</p>
<p>Der Link wurde dir von $_user zugeschickt</p> 
 

<form action =".$PHP_SELF." method = post> 

// Formulat mit Submit-Button

</form>";

if(isset($_POST['speichern']))
{            
    include "DB.php"; // für DB Verbindung 

    $sql = "SELECT
				gast_ID
            FROM
                Teballe";
          
    $result = mysql_query($sql);
    mysql_num_rows($result);
                    
    while($row = mysql_fetch_assoc($result)) 
    {
        $password = $row['gast_ID'];

        if($password == $_id) // <--  $_id ist unbekannt !
        {
                   // mach kopfstand
                }
    }
}

echo "</body>";
echo "</html>";

?>
 
Prüf doch mal, ob deine Datenbankabfrage überhaupt in der Form funktioniert.
Was willst du denn mit
PHP:
mysql_num_rows($result);
bezwecken?
 
Gibt er Dir tatsächlich eine Notice oder Warning, oder passiert einfach nicht das, was Du innerhalb des if-Body tun willst?
Kann es sein, dass es Tabelle, statt Teballe heißen muss?
Ansonsten nach dem Query mal
PHP:
echo mysql_error();
machen und schauen, ob es eine MySQL-Fehlermeldung gibt.
Oder in der id steht einfach nicht das "richtige" drin, also eine id, die niemals gleich dem Passwort ist. (Warum id gleich Passwort?)
Nach PHP-Syntax ist die dort unten bekannt, wenn sie nicht mit unset "gelöscht" wurde.
 
Es hat nichts mit der MySQL Abfrage zutun

Hier habe ich die MySQL Abfrage entfernt .. mein Problem: Die Variblen werden ganz unten nicht erkannt !

Gruß
Aaron


Code:
<?php 
// error_reporting(E_ALL); 

$_id = $_GET['id'];
$_guest = $_GET['guest'];
$_user  = $_GET['user'];

// print_r($_GET);

echo "<html> 
<head> 
<title></title> 
</head> 

<body bgcolor=#CCCCCC> 
<p>Hallo $_guest,<br>Damit $_user rechtzeitig über Deinen Geburtstag informiert wird, müss das Eingabefeld ( <strong>Vorname</strong> und <strong>Geburtsdatum</strong> ) ausgefüllt werden. Die restlichen Felder sind optional.</p>
<hr><br>
 
<form action =".$PHP_SELF." method = post> 

<table width=100% border=0>
  <tr> 
    <td width=17%><strong>Vorname</strong></td>
    <td width=83%>Nachname</td>
  </tr>
  <tr>
    <td>
        <input name=myVorname type=text>
    </td>
    <td>
        <input name=myNachname type=text>
    </td>
  </tr>
</table>
<table width=100% border=0>
  <tr>
    <td><strong>Geburtsdatum</strong></td>
  </tr>
  <tr>
    <td>
        <select name=myTag id=myTag>
          <option selected>Tag</option>
          <option>01</option>
          <option>02</option>
          <option>03</option>
          <option>04</option>
          <option>05</option>
          <option>06</option>
          <option>07</option>
          <option>08</option>
          <option>09</option>
          <option>10</option>
          <option>11</option>
          <option>12</option>
          <option>13</option>
          <option>14</option>
          <option>15</option>
          <option>16</option>
          <option>17</option>
          <option>18</option>
          <option>19</option>
          <option>20</option>
          <option>21</option>
          <option>22</option>
          <option>23</option>
          <option>24</option>
          <option>25</option>
          <option>26</option>
          <option>27</option>
          <option>28</option>
          <option>29</option>
          <option>30</option>
          <option>31</option>
        </select>
        <select name=myMonat id=myMonat>
          <option selected>Monat</option>
          <option>01</option>
          <option>02</option>
          <option>03</option>
          <option>04</option>
          <option>05</option>
          <option>06</option>
          <option>07</option>
          <option>08</option>
          <option>09</option>
          <option>10</option>
          <option>11</option>
          <option>12</option>
        </select>
        <select name=myJahr id=myJahr>
          <option selected>Jahr</option>
          <option>1910</option>
	  <option>1911</option>
	  <option>1912</option>
	  <option>1913</option>
	  <option>1914</option>
	  <option>1915</option>
	  <option>1916</option>
	  <option>1917</option>
	  <option>1918</option>
	  <option>1919</option>
          <option>1920</option>
	  <option>1921</option>
	  <option>1922</option>
	  <option>1923</option>
	  <option>1924</option>
	  <option>1925</option>
	  <option>1926</option>
	  <option>1927</option>
	  <option>1928</option>
	  <option>1929</option>
          <option>1930</option>
	  <option>1931</option>
	  <option>1932</option>
	  <option>1933</option>
	  <option>1934</option>
	  <option>1935</option>
	  <option>1936</option>
	  <option>1937</option>
	  <option>1938</option>
	  <option>1939</option>
          <option>1940</option>
	  <option>1941</option>
	  <option>1942</option>
	  <option>1943</option>
	  <option>1944</option>
	  <option>1945</option>
	  <option>1946</option>
	  <option>1947</option>
	  <option>1948</option>
	  <option>1949</option>
          <option>1950</option>
	  <option>1951</option>
	  <option>1952</option>
	  <option>1953</option>
	  <option>1954</option>
	  <option>1955</option>
	  <option>1956</option>
	  <option>1957</option>
	  <option>1958</option>
	  <option>1959</option>
          <option>1960</option>
	  <option>1961</option>
	  <option>1962</option>
	  <option>1963</option>
	  <option>1964</option>
	  <option>1965</option>
	  <option>1966</option>
	  <option>1967</option>
	  <option>1968</option>
	  <option>1969</option>
          <option>1970</option>
	  <option>1971</option>
	  <option>1972</option>
	  <option>1973</option>
	  <option>1974</option>
	  <option>1975</option>
	  <option>1976</option>
	  <option>1977</option>
	  <option>1978</option>
	  <option>1979</option>
          <option>1980</option>
	  <option>1981</option>
	  <option>1982</option>
	  <option>1983</option>
	  <option>1984</option>
	  <option>1985</option>
	  <option>1986</option>
	  <option>1987</option>
	  <option>1988</option>
	  <option>1989</option>
          <option>1990</option>
	  <option>1991</option>
	  <option>1992</option>
	  <option>1993</option>
	  <option>1994</option>
	  <option>1995</option>
	  <option>1996</option>
	  <option>1997</option>
	  <option>1998</option>
	  <option>1999</option>
	  <option>2000</option>
	  <option>2001</option>
	  <option>2002</option>
	  <option>2003</option>
	  <option>2004</option>
      </select>
      </td>
  </tr>
</table>
<table width=100% border=0>
  <tr>
    <td width=17%>Stra&szlig;e</td>
    <td width=17%>PLZ</td>
    <td width=66%>Ort</td>
  </tr>
  <tr>
    <td>
        <input name=myStrasse type=text>
    </td>
    <td>
        <input name=myPlz type=text>
    </td>
    <td>
        <input name=myOrt type=text>
    </td>
  </tr>
</table>
<table width=100% border=0>
  <tr>
    <td width=17%>Festnetz</td>
    <td width=83%>Handy</td>
  </tr>
  <tr>
    <td>
        <input name=myFestnetz type=text>
    </td>
    <td>
        <input name=myHandy type=text>
    </td>
  </tr>
</table>
<table width=100% border=0>
  <tr>
    <td>E-Mail</td>
  </tr>
  <tr>
    <td>
        <input name=myEmail type=text>
    </td>
  </tr>
</table>
<table width=100% border=0>
  <tr>
    <td>ICQ / MSN</td>
  </tr>
  <tr>
    <td>
        <input name=myIcq type=text>
    </td>
  </tr>
</table>
<table width=100% border=0>
  <tr>
      <td>Webseite URL</td>
  </tr>
  <tr>
    <td>
        <input name=myWebseite type=text id=myWebseite>
    </td>
  </tr>
</table>
  <table width=100% border=0>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align=left>
          <input name=_speichern type=submit id=_speichern value='      Speichern      '>
    </div></td>
  </tr>
</table>

</form>";

if(isset($_POST['_speichern']))
{	
	echo "!";		
	echo "<br>".$_id."<br>";
	echo $_guest."<br>";
	echo $user;									   
} 

echo "</body>";
echo "</html>";

?>
 
Wenn du deine Formulardaten per Post übergibst, kannst du nicht über das Array $_GET darauf zugreifen. Du solltest dir auch angewöhnen, validen HTML-Code zu schreiben.
 
eine Möglichkeit: id steht in $_POST und nicht in $_GET steht.
Das gilt natürlich nur, wenn Deine URL aus dem ersten Post nur ein Beipiel ist und die id eigentlich aus einem Formular kommt.
Wie lautet denn die Fehlermeldung oder ist die Variable einfach leer?
Gibt er das Ausfufezeichen aus?
$_POST['_speichern'] ist leer, wenn Du über die URL kommst.
Wenn Du über ein Formular kommst steht die ID vermutlich in $_POST und nicht in $_GET.
Ich habe schon Webserver gesehen, die eine URI mit GET-Parametern als Formularziel (mit POST) nicht richtig verarbeiten.
Gibt er $_id denn direkt nach dem Zuweisen richtig aus?
Es fehlen einige Informationen, um das Problem näher ein zu grenzen.
Vor allem: Gibt es eine Fehlermeldung oder ist die Variable leer?
Soviel zu weiteren Ideen.

Gruß hpvw
 
Huhu..

Danke für euere Antworten..

Gelöst habe ich das Problem durch ein "hidden" Eingabefeld.

..kann die Werte jetzt einfach in "hidden" zwischenspeichern und per post abgreifen.

Gruß
Aaron
 
Zurück