PDA

Bekijk Volledige Versie : PHP Geposte variabel behoud de waarde niet na submit in eigen form. Help!!!!!!!! al een hele week be



expodium
04/01/03, 14:50
hey aan idd.

volgend probleem heb ik.

Ik heb 2 php formulieren. In form a wordt een variabel door middel van POST
doorgegeven naar form B.
Daardoor kan ik zien in welke ruimte nog een datum vrij is.

Dat lukt goed.

Nu heb ik ook in Form B 2 buttons staan om van maand te veranderen. Als ik
nu van maand verander, dan gaat de variabel terug leeg. Wat nu juist niet
mag zijn.

je kan dit eventueel bekijken op http://81.82.14.173:7060/1/index.htm en
naar de link repetitieruimte te gaan.

wel even inloggen met username "test" en paswoord "test"

de code is: (bekijk de rood gemarkeerde tekst in de code)

<?
//header ("Cache-Control: no-cache, must-revalidate");
//header ("Pragma: no-cache");
$hash = md5($HTTP_COOKIE_VARS["username"].$HTTP_COOKIE_VARS["userpass"]);
$hash2 = md5($HTTP_COOKIE_VARS["username"]);
//Oke de hash is gemaakt, nu de nieuwe hash met de hash in de cookie
vergelijken.
if($hash == $userhash) {

} else {
?><HTML><link href="html_expo.css" rel="stylesheet" type="text/css">
<body class="test">U bent niet aangelogd of u bent nog niet
geregistreerd<P>Ga via de menu boven terug naar het inlogscherm of
registreer u</html><?
exit;
}
function gepland_of_niet($counter,$datum)
{
$replis = $_POST['Naam_r']; //geposte variabel van Form A
$db=mysql_connect("localhost","test","test");
$result=mysql_select_db("testdb",$db);
$query = mysql_query("SELECT * FROM agenda WHERE datum='$datum' AND
Naam_r2='$replis'");
$aantal = mysql_num_rows($query);
if ($aantal==0)
{
$stuff = "<td valign=top $xtra><B>$counter</B>.<BR>Nog Vrij.</td>";
return $stuff;

}
else
{
$stuff = "<td valign=top bgcolor=#F4F4F4 $xtra><B><font
color=red>$counter</B>.";
while ($row = mysql_fetch_object($query))
{
$titel = $row->titel;
if (strlen($titel) > 15)
{
$titel = substr($titel,0,15)."...";
}
$stuff .= "<BR>. <a href=\"agenda_item.php?ID=$row->ID\"
title=\"BEKIJK: $row->titel\">$titel";
}




$stuff .= "</font></td>";
return $stuff;
//
}

}
?>

<script>
function navigate(url)
{
this.location = url;
}
</script>

<?
if ($year=='') {
$year=date(Y,time());
}

if ($month=='') {
$month=date(m,time());
$month_text = mktime(0,0,0,$month,1,$year);
$month_text = date(F,$month_text);
}


$month_text = mktime(0,0,0,$month,1,$year);
$month_text = date(F,$month_text);
if ($month==1) $maand = "Januari";
if ($month==2) $maand = "Februari";
if ($month==3) $maand = "Maart";
if ($month==4) $maand = "April";
if ($month==5) $maand = "Mei";
if ($month==6) $maand = "Juni";
if ($month==7) $maand = "Juli";
if ($month==8) $maand = "Augustus";
if ($month==9) $maand = "September";
if ($month==10) $maand = "Oktober";
if ($month==11) $maand = "November";
if ($month==12) $maand = "December";

print "<BR><BR><font size=+1>Overzicht van de maand <B>$maand</B> in het
jaar <B>$year</B></font>";

echo "
<table class=menu width=100% cellspacing=1 cellpadding=2 border=1>

<tr>
<th class=barheader>Zondag</th>
<th class=barheader>Maandag</th>
<th class=barheader>Dinsdag</th>
<th class=barheader>Woensdag</th>
<th class=barheader>Donderdag</th>
<th class=barheader>Vrijdag</th>
<th class=barheader>Zaterdag</th>
</tr>\n";


$nextmonth = $month+1;
$lastday = mktime(0,0,0,$nextmonth,0,$year);
$lastday = date(d,$lastday);

$firstday = mktime(0,0,0,$month,1,$year);
$day_of_week = date(l,$firstday);
print "<tr>";
if($day_of_week=='Monday') { echo str_repeat("<td></td>",1); }
else if($day_of_week=='Tuesday') { echo str_repeat("<td></td>",2); }
else if($day_of_week=='Wednesday') { echo str_repeat("<td></td>",3); }
else if($day_of_week=='Thursday') { echo str_repeat("<td></td>",4); }
else if($day_of_week=='Friday') { echo str_repeat("<td></td>",5); }
else if($day_of_week=='Saturday') { echo str_repeat("<td></td>",6); }

$counter=1;
while($counter<=$lastday)
{
if (strlen($counter)==1)
{
$dag = "0$counter";
}
else
{
$dag = $counter;
}
if (strlen($month)==1)
{
$maand = "0$month";
}
else
{
$maand = $month;
}
$nu_datum = "$dag$maand$year";

$day = mktime(0,0,0,$month,$counter,$year);
$day_of_week = date(l,$day);
if($day_of_week == 'Sunday') { print "<tr>"; }

echo gepland_of_niet($counter,$nu_datum);



if($day_of_week == 'Saturday') { print "</tr>\n"; }

$counter++;

}


print "
</table>

</td><td>

</td></tr></table>
\n";
$replis = $_POST['Naam_r'];
$volgendemaand = $month+1;
if ($volgendemaand==13)
{
$volgendemaand = 1;
$volgendjaar = $year+1;
}
else
{
$volgendjaar = $year;
}


$vorigemaand = $month-1;
if ($vorigemaand=="0")
{
$vorigemaand = 12;
$vorigjaar = $year-1;
}
else
{
$vorigjaar = $year;
}
$Naam_r = $replis;
echo "<input type=button size=15 value=\"Vorige Maand\"
onclick=\"javascript:navigate('agenda.php?year=$vorigjaar&month=$vorigemaand
')\">";
echo " <input type=button size=15 value=\"Volgende Maand\"
onclick=\"javascript:navigate('agenda.php?year=$volgendjaar&month=$volgendem
aand')\">";
// bij deze buttons wil ik graag de variabel weer posten. Kan dat?? zo ja,
hoe?? Daar ben ik nu al een hele week mee bezig en vind nergens een
oplossing.
echo $_POST['Naam_r'];
?>
<link href="html_expo.css" rel="stylesheet" type="text/css">
<body class="test4">
<form method=post>
Spring naar: <select name=month><option value=1>Januari<option
value=2>Februari<option value=3>Maart<option value=4>April<option
value=5>Mei<option value=6>Juni<option value=7>Juli<option
value=8>Augustus<option value=9>September<option value=10>Oktober<option
value=11>November<option value=12>December</select>
<select name=year><option value=2000>2000<option value=2001>2001<option
value=2002>2002<option value=2003 ><option value=2004
selected>2004</select><input type=submit value="Go!"></form>
</select>

Hopende dat er iemand is die me ermee kan helpen.

expodium

www.expodium.be