Jump to content
php.lv forumi

Problemas ar [ID] = PHP Soli pa Solim! - Gramatas kludas!


didy

Recommended Posts

1.

 

<html>
<head>
<title>latbit.lv</title>
</head>
<body>
<form action="index1.php" method="post">
<strong><font color="#FF0000">Iepazistini ar sevi!:</font></strong><br /><br />
<table width="310" cellspacing="0" cellpadding="0">
 <tr>
<td colspan="2" align="center"><b>Personiga inforimacija :</b></td>
 </tr>
 <tr>
<td width="119">Vards:</td>
<td width="183"><input type="text" name="vards"></td>
 </tr>
 <tr>
<td>Uzvards:</td>
<td><input type="text" name="uzvards"></td>
 </tr>
 <tr>
<td>E-pasts:</td>
<td><input type="text" name="epasts"></td>
 </tr>
 <tr>
<td colspan="2" align="center"><b>Informacija par darbu:</b></td>
 </tr>
 <tr>
<td>Firmas nosaukums: </td>
<td><input type="text" name="fn"></td>
 </tr>
 <tr>
<td>Ienemamais amats:</td>
<td><input type="text" name="ia"></td>
 </tr>
 <tr>
<td>Telefons darba: </td>
<td><input type="text" name="tel"></td>
 </tr>
 <tr>
<td colspan="2" align="center"><b>Tava aizrausanas:</b></td>
 </tr>
 <tr>
<td>Sports</td>
<td><input type="radio" name="aizr" value="sports"></td>
 </tr>
 <tr>
<td>Programesana</td>
<td><input type="radio" name="aizr" value="programesana"></td>
 </tr>
 <tr>
<td>Literatura</td>
<td><input type="radio" name="aizr" value="literatura"></td>
 </tr>
 <tr>
<td></td>
<td><input type="submit" value="Apstiprinat"><input type="reset" value="Dzest"></td>
 </tr>
</table>
</form>
</body>
</html>

 

2.

 

<html>
<head>
<title>latbit.lv</title>
</head>
<body>
<h3>Izvelies Tevi interesejosu informaciju:</h3>
<?
$vards = $_POST['vards'];
$uzvards = $_POST['uzvards'];
$epasts = $_POST['epasts'];
echo ("<a href=\"index2.php\?vards=$vards&uzvards=$uzvards&epasts=$epasts&id=1\">personiga informacija</a><br />\n");
$fn = $_POST['fn'];
$ia = $_POST['ia'];
$tel = $_POST['tel'];
echo ("<a href=\"index2.php\?fn=$fn&ia=$ia&tel=$tel&id=2\">darba inforimacija</a><br />\n");
$aizr = $_POST['aizr'];
echo ("<a href=\"index2.php\?aizr=$aizr&id=3\">aizrausanas</a>\n");
?>
</body>
</html>

 

3.

<html>
<head>
<title>latbit.lv</title>
</head>
<body>
<h3>Tu pieprasiji sekojosu informaciju:</h3>
<table>
<?
if ($id ==1){
$vards = $_GET['vards'];
$uzvards = $_GET['uzvards'];
$epasts = $_GET['epasts'];
echo ("<tr><th colspan=\"2\">Personiga inforimacija:</tr>\n");
echo ("<tr><td>Vards:</td><td><i>$vards</i></td></tr>\n");
echo ("<tr><td>Uzvards:</td><td><i>$uzvards</i></td></tr>\n");
echo ("<tr><td>E-pasts:</td><td><i>$epasts</i></td></tr>\n");
}
elseif ($id == 2) {
$fn = $_GET['fn'];
$ia = $_GET['ia'];
$tel = $_GET['tel'];
echo ("<tr><th colspan=\"2\">Darba inforimacija:</tr>\n");
echo ("<tr><td>Firmas nosaukums:</td><td><i>$fn</i></td></tr>\n");
echo ("<tr><td>Ienemamais amats:</td><td><i>$ia</i></td></tr>\n");
echo ("<tr><td>Darba telefons:</td><td><i>$tel</i></td></tr>\n");
}
else {
$aizr = $_GET['aizr'];
echo ("<tr><td>Aizrausanas:</td><td><i>$aizr</i></td></tr>\n");
}
?>
</table>
</body>
</html>

 

Problema ar id:

 

Notice: Undefined variable: id in c:\program files\easyphp1-8\www\index2.php on line 9

 

Notice: Undefined variable: id in c:\program files\easyphp1-8\www\index2.php on line 18

 

Notice: Undefined index: aizr in c:\program files\easyphp1-8\www\index2.php on line 28

 

- Macos no gramatas PHP Soli Pa Solim (veca gramata - ar kludam) bet so kludu jau pari dienas nevaru atkost! Kads nevaretu palidzet?

Link to comment
Share on other sites

ehh.. RTFM!

Grāmata ir novecojusi un lieto nelabas konstrukcijas.

Visus mainīgos, kurus tu saņem no GET, POST, COOKIES vai no sesijas mainīgajiem, vajag piekļūt nevis kā parastam mainīgajama $id, bet gan norādot, no kuriens tas nāk: $_GET['id'] vai $_POST['id'], utt.

 

Būtu searchā tepat ierakstījis kļūdas paziņojumu, dabūtu daudz topiku ar atbildi uz savu jautājumu.

Link to comment
Share on other sites

3.

<html>
<head>
<title>latbit.lv</title>
</head>
<body>
<h3>Tu pieprasiji sekojosu informaciju:</h3>
<table>
<?
$id=$_GET['id'];
if ($id ==1){
$vards = $_GET['vards'];
$uzvards = $_GET['uzvards'];
$epasts = $_GET['epasts'];
echo ("<tr><th colspan=\"2\">Personiga inforimacija:</tr>\n");
echo ("<tr><td>Vards:</td><td><i>$vards</i></td></tr>\n");
echo ("<tr><td>Uzvards:</td><td><i>$uzvards</i></td></tr>\n");
echo ("<tr><td>E-pasts:</td><td><i>$epasts</i></td></tr>\n");
}
elseif ($id == 2) {
$fn = $_GET['fn'];
$ia = $_GET['ia'];
$tel = $_GET['tel'];
echo ("<tr><th colspan=\"2\">Darba inforimacija:</tr>\n");
echo ("<tr><td>Firmas nosaukums:</td><td><i>$fn</i></td></tr>\n");
echo ("<tr><td>Ienemamais amats:</td><td><i>$ia</i></td></tr>\n");
echo ("<tr><td>Darba telefons:</td><td><i>$tel</i></td></tr>\n");
}
else {
$aizr = $_GET['aizr'];
echo ("<tr><td>Aizrausanas:</td><td><i>$aizr</i></td></tr>\n");
}
?>
</table>
</body>
</html>

tādi topiki ir katru otro dienu, kuru es šeit esmu..

Edited by Stopp
Link to comment
Share on other sites

×
×
  • Create New...