Formulier werkt niet (Opgelost) 		
			
		
		 		
				
		
                        
                 
            
            
				
                
                    Gezienus (laatste wijziging 25/06/2011 21:30)                       
             
             
                        
                Lid 
				
				Voor het vullen van uitslagen van wedstrijden wil ik het volgende formulier gebruiken. 
    
    
        
            
                echo "<form method='post' name='form' action='$PHP_SELF'>";
echo "<table width='805' border='0' class='hoofdtekst_2'><tr><td width='85'>$datum</td><td width='45'>$tijd</td><td width='50'>$nummer</td><td width='130' align='right'>$thuis</td><td width='10' align='center'>-</td><td width='180'>$uit</td><td width='65' align='right'><input name='score_thuis' type='text' style='width:50px' /></td><td width='10'>-</td><td width='65'><input name='score_uit' type='text' style='width:50px' /></td><td width='165'> </td></tr>";
	}
echo "<tr><td colspan='10'> </td></tr><tr><td></td><td valign='top' colspan='9'><input type='Submit' value='Uitslagen toevoegen'></td></tr></table>
</form>";
if($_SERVER['REQUEST_METHOD'] == 'POST') {
for($i=0;$i<$count;$i++){
	$id = $_POST['id'];
	$score_thuis = $_POST['score_thuis'];
    $score_uit = $_POST['score_uit'];
$sql_update= mysql_query("UPDATE wedstrijden SET score_thuis='$score_thuis[$i]', score_uit='$score_uit[$i]' WHERE id='$id[$i]'") or trigger_error(mysql_error(),E_USER_ERROR);
}
echo '<meta http-equiv="refresh" content="0;URL=?location=uitslagen" />';
}
 
             
            echo "<form method='post' name='form' action='$PHP_SELF '>" ; echo "<table width='805' border='0' class='hoofdtekst_2'><tr><td width='85'>$datum </td><td width='45'>$tijd </td><td width='50'>$nummer </td><td width='130' align='right'>$thuis </td><td width='10' align='center'>-</td><td width='180'>$uit </td><td width='65' align='right'><input name='score_thuis' type='text' style='width:50px' /></td><td width='10'>-</td><td width='65'><input name='score_uit' type='text' style='width:50px' /></td><td width='165'> </td></tr>" ; 	} 
echo "<tr><td colspan='10'> </td></tr><tr><td></td><td valign='top' colspan='9'><input type='Submit' value='Uitslagen toevoegen'></td></tr></table> </form>" ; 
 
 
if ( $_SERVER [ 'REQUEST_METHOD' ]  ==  'POST' )  { 
 
for ( $i = 0 ; $i < $count ; $i ++ ) { 
	$id  =  $_POST [ 'id' ] ; 
	$score_thuis  =  $_POST [ 'score_thuis' ] ; 
    $score_uit  =  $_POST [ 'score_uit' ] ; 
 
 
} 
echo '<meta http-equiv="refresh" content="0;URL=?location=uitslagen" />' ; } 
 
         
     
  
              
        
		
				
		25 antwoorden 
                
                     
                
                    
		
		
	             
 
            
                    
                         
                    
                    
                        
                            Bv202 (laatste wijziging 25/06/2011 21:41)                             
                         
                     
                    
                        Lid Wat is $PHP_SELF? Het is $_SERVER['PHP_SELF'] (tenzij je dat bewust in een aparte variabele hebt gestoken?) http://www.scri...te-phpself  
                      
                
                    
                         
                    
                    
                        
                            Gezienus (laatste wijziging 25/06/2011 21:55)                             
                         
                     
                    
                        Lid $PHP_SELF? is niet het probleem. Bij andere pagina's werkt dit wel. 
                      
                
                    
                         
                    
                    
                        
                            FrankL                             
                         
                     
                    
                        Lid Probeer het eens door bij iedere variabele die je in de html stukken hebt dit te doen:
    
    
        
            
                
"<form method='post' name='form' action='".$PHP_SELF."'>"; 
             
            "<form method='post' name='form' action='" . $PHP_SELF . "'>" ; 
 
         
     
  
                      
                
                    
                         
                    
                    
                        
                            mwthomas                             
                         
                     
                    
                        Lid Gebruik $_SERVER['PHP_SELF']
    
    
        
            
                
$sql_update= mysql_query("UPDATE wedstrijden SET score_thuis='$score_thuis[$i]', score_uit='$score_uit[$i]' WHERE id='$id[$i]'") or trigger_error(mysql_error(),E_USER_ERROR);
 
             
            
         
         
     
 
    
    
        
            
                
$sql_update= mysql_query("UPDATE wedstrijden SET score_thuis='".$score_thuis[$i]."', score_uit='".$score_uit[$i]."' WHERE id='".$id[$i]."'") or trigger_error(mysql_error(),E_USER_ERROR);
 
             
            $sql_update =  mysql_query ( "UPDATE wedstrijden SET score_thuis='" . $score_thuis [ $i ] . "', score_uit='" . $score_uit [ $i ] . "' WHERE id='" . $id [ $i ] . "'" )  or 
trigger_error ( mysql_error ( ) , E_USER_ERROR ) ;  
         
     
  
                      
                
                    
                         
                    
                    
                        
                            Gezienus (laatste wijziging 26/06/2011 10:46)                             
                         
                     
                    
                        Lid Ik heb nu de volgende code:
    
    
        
            
                <?php
include ("authorized.php");
include ("../config/config.php");
echo "<div id='main_border'><table width='805' border='0'><tr class='blok2'><td>Uitslagen invoeren</td></tr></table><br />";
   
echo "<table width='805px' class='blok3' border='0'><tr><td width='85'>Datum</td><td width='45'>Tijd</td><td width='50'>Nr.</td><td width='130' align='right'>Thuis</td><td width='10' align='center'></td><td width='180'>Uit</td><td width='140' align='center'>Uitslag</td><td width='165'></td></tr></table><br>";
$sql = mysql_query("SELECT * FROM wedstrijden  WHERE (datum <= current_date()) AND (score_thuis IS NULL) ORDER BY datum ASC") or trigger_error(mysql_error(),E_USER_ERROR);
    while ($row = mysql_fetch_array($sql)) {
		$id = $row['id'];
		$team = $row['team'];
                $date = $row['datum'];
                $time = $row['tijd'];
		$nummer = $row['wedstrijdnummer'];
                $thuis = $row['thuis'];
                $uit = $row['uit'];
                $score_thuis = $row['score_thuis'];
                $score_uit = $row['score_uit'];
		$tijd = cnv_tijd($time);
		$datum = cnv_dat($date);
		$count=mysql_num_rows($sql);
		
echo "<form method='post' name='form' action='".$_SERVER['PHP_SELF']."'>";
echo "<table width='805' border='0' class='hoofdtekst_2'><tr><td width='85'>".$datum."</td><td width='45'>".$tijd."</td><td width='50'>".$nummer."</td><td width='130' align='right'>".$thuis."</td><td width='10' align='center'>-</td><td width='180'>".$uit."</td><td width='65' align='right'><input name='".score_thuis."' type='text' style='width:50px' /></td><td width='10'>-</td><td width='65'><input name='".score_uit."' type='text' style='width:50px' /></td><td width='165'> </td></tr>";
	}
echo "<tr><td colspan='10'> </td></tr><tr><td></td><td valign='top' colspan='9'><input type='Submit' value='Uitslagen toevoegen'></td></tr></table>
</form>";
if($_SERVER['REQUEST_METHOD'] == 'POST') {
for($i=0;$i<$count;$i++){
	$id = $_POST['id'];
	$score_thuis = mysql_real_escape_string($_POST['score_thuis']);
        $score_uit = mysql_real_escape_string($_POST['score_uit']);
$sql_update= mysql_query("UPDATE wedstrijden SET score_thuis='".$score_thuis[$i]."', score_uit='".$score_uit[$i]."' WHERE id='".$id[$i]."'") or trigger_error(mysql_error(),E_USER_ERROR);
}
echo '<meta http-equiv="refresh" content="0;URL=?location=uitslagen" />';
}
echo "</div>";
?>
 
             
            <?php 
include  ( "authorized.php" ) ; 
include  ( "../config/config.php" ) ; 
 
echo "<div id='main_border'><table width='805' border='0'><tr class='blok2'><td>Uitslagen invoeren</td></tr></table><br />" ;  
echo "<table width='805px' class='blok3' border='0'><tr><td width='85'>Datum</td><td width='45'>Tijd</td><td width='50'>Nr.</td><td width='130' align='right'>Thuis</td><td width='10' align='center'></td><td width='180'>Uit</td><td width='140' align='center'>Uitslag</td><td width='165'></td></tr></table><br>" ;  
		$id  =  $row [ 'id' ] ; 
		$team  =  $row [ 'team' ] ; 
                $date  =  $row [ 'datum' ] ; 
                $time  =  $row [ 'tijd' ] ; 
		$nummer  =  $row [ 'wedstrijdnummer' ] ; 
                $thuis  =  $row [ 'thuis' ] ; 
                $uit  =  $row [ 'uit' ] ; 
                $score_thuis  =  $row [ 'score_thuis' ] ; 
                $score_uit  =  $row [ 'score_uit' ] ; 
		$tijd  =  cnv_tijd( $time ) ; 
		$datum  =  cnv_dat( $date ) ; 
 
echo "<form method='post' name='form' action='" . $_SERVER [ 'PHP_SELF' ] . "'>" ; echo "<table width='805' border='0' class='hoofdtekst_2'><tr><td width='85'>" . $datum . "</td><td width='45'>" . $tijd . "</td><td width='50'>" . $nummer . "</td><td width='130' align='right'>" . $thuis . "</td><td width='10' align='center'>-</td><td width='180'>" . $uit . "</td><td width='65' align='right'><input name='" . score_thuis
. "' type='text' style='width:50px' /></td><td width='10'>-</td><td width='65'><input name='" . score_uit
. "' type='text' style='width:50px' /></td><td width='165'> </td></tr>" ;  
 
	} 
echo "<tr><td colspan='10'> </td></tr><tr><td></td><td valign='top' colspan='9'><input type='Submit' value='Uitslagen toevoegen'></td></tr></table> </form>" ; 
 
 
if ( $_SERVER [ 'REQUEST_METHOD' ]  ==  'POST' )  { 
 
for ( $i = 0 ; $i < $count ; $i ++ ) { 
	$id  =  $_POST [ 'id' ] ; 
 
$sql_update =  mysql_query ( "UPDATE wedstrijden SET score_thuis='" . $score_thuis [ $i ] . "', score_uit='" . $score_uit [ $i ] . "' WHERE id='" . $id [ $i ] . "'" )  or 
trigger_error ( mysql_error ( ) , E_USER_ERROR ) ; } 
echo '<meta http-equiv="refresh" content="0;URL=?location=uitslagen" />' ; } 
?> 
 
         
     
  
                      
                
                    
                         
                    
                    
                        
                            FrankL                             
                         
                     
                    
                        Lid <input name='".score_thuis."' .... 
                      
                
                    
                         
                    
                    
                        
                            Gezienus (laatste wijziging 26/06/2011 17:14)                             
                         
                     
                    
                        Lid <input name='".score_thuis."' .... was ik inmiddels achter dat het niet correct is. 
                      
                
                    
                         
                    
                    
                        
                            Aar                             
                         
                     
                    
                        PHP interesse je metatag staat verkeerd geplaatst...... 
                      
                
                    
                         
                    
                    
                        
                            FrankL                             
                         
                     
                    
                        Lid id wordt wel opgehaald in de SELECT query, maar vervolgens noem je $id=$_POST['id'] en dat kan niet, want $_POST['id'] gaat niks opleveren;) 
                      
                
                    
                         
                    
                    
                        
                            Gezienus (laatste wijziging 26/06/2011 17:17)                             
                         
                     
                    
                        Lid Wie kan mij dan vertellen hoe het wel moet? 
                      
                
                    
                         
                    
                    
                        
                            FrankL                             
                         
                     
                    
                        Lid Zou je toevallig je database structuur/eventuele gegevens eruit kunnen posten hier, dan kan ik het even testen. 
                      
                
                    
                         
                    
                    
                        
                            Gezienus                             
                         
                     
                    
                        Lid en hoe doe ik dat? ik heb eeb zip-file 
                      
                
                    
                         
                    
                    
                        
                            FrankL                             
                         
                     
                    
                        Lid je zou hier kunnen aangeven welke velden je hebt in je tabel, en daarbij horende gegevens als : is het int of varchar enz. 
                      
                
                    
                         
                    
                    
                        
                            Gezienus                             
                         
                     
                    
                        Lid Tabelstructuur voor tabel `wedstrijden` 
                      
                
                    
                         
                    
                    
                        
                            FrankL (laatste wijziging 26/06/2011 18:49)                             
                         
                     
                    
                        Lid ja, dankje:) 
                      
                
                    
                         
                    
                    
                        
                            Gezienus                             
                         
                     
                    
                        Lid Heb je  hier nog naar gekeken. 
                      
                
                    
                         
                    
                    
                        
                            FrankL                             
                         
                     
                    
                        Lid Ik heb er nog nagekeken, maar het lukte helaas niet;) Het spijt me. Ik kan je wel het script geven dat er telkens 1 toevoegd:P  
                      
                
                    
                         
                    
                    
                        
                            Gezienus                             
                         
                     
                    
                        Lid Iemand anders misschien nog een suggestie? 
                      
                
                    
                         
                    
                    
                        
                            Wijnand                             
                         
                     
                    
                        Moderator 1. Kun je bij die POST even de $count echo-en? 
                      
                
                    
                         
                    
                    
                        
                            Gezienus                             
                         
                     
                    
                        Lid Ik ben de draad volledig kwijt
    
    
        
            
                <?php
include ("authorized.php");
include ("../config/config.php");
error_reporting(E_ALL); 
ini_set('display_errors',1);
echo "<div id='main_border'>";
echo "<table width='805' border='0'><tr class='blok2'><td>Uitslagen invoeren</td></tr></table><br />";
   
echo "<table width='805px' class='blok3' border='0'><tr><td width='25'>id</td><td width='85'>Datum</td><td width='45'>Tijd</td><td width='50'>Nr.</td><td width='130' align='right'>Thuis</td><td width='10' align='center'></td><td width='180'>Uit</td><td width='140' align='center'>Uitslag</td><td width='140'></td></tr></table><br>";
$sql = mysql_query("SELECT * FROM wedstrijden  WHERE (datum <= current_date()) AND (score_thuis IS NULL) ORDER BY datum ASC") or trigger_error(mysql_error(),E_USER_ERROR);
    while ($row = mysql_fetch_array($sql)) {
		$id = $row['id'];
		$team = $row['team'];
        $date = $row['datum'];
        $time = $row['tijd'];
		$nummer = $row['wedstrijdnummer'];
        $thuis = $row['thuis'];
        $uit = $row['uit'];
        $score_thuis[] = $row['score_thuis'];
        $score_uit[] = $row['score_uit'];
		$tijd = cnv_tijd($time);
		$datum = cnv_dat($date);
		$count=mysql_num_rows($sql);
echo "<form method='post' name='form'>";
echo "<table width='805' border='0' class='hoofdtekst_2'><tr><td><input name='id[]' type='hidden' ></td><td width='25'>$id</td><td width='85'>$datum</td><td width='45'>$tijd</td><td width='50'>$nummer</td><td width='130' align='right'>$thuis</td><td width='10' align='center'>-</td><td width='180'>$uit</td><td width='65' align='right'><input name='score_thuis[]' type='text' style='width:30px' ></td><td width='10' align='center'>-</td><td width='65'><input name='score_uit[]' type='text' style='width:30px' ></td><td width='140'> </td></tr></table>";
}
echo "<table><td colspan='10'> </td></tr><tr><td></td><td valign='top' colspan='9'><input type='Submit' value='Uitslagen toevoegen'></td></tr></table>
</form>";
if($_SERVER['REQUEST_METHOD'] == "POST") {
for ($i=0;$i<$count;$i++){
	$score_thuis = mysql_real_escape_string($_POST['score_thuis']);
    $score_uit = mysql_real_escape_string($_POST['score_uit']);
$sql_update= mysql_query("UPDATE wedstrijden SET score_thuis='$score_thuis[$i]', score_uit='$score_uit[$i]' WHERE id='$id[$i]'") or trigger_error(mysql_error(),E_USER_ERROR);
echo "$count";
echo "$id  -  ";
echo " score_thuis='".$score_thuis[$i]."', score_uit='".$score_uit[$i]."', id='".$id[$i]."';<br />";
}
//echo "<meta http-equiv='refresh' content='0;URL=index.php?location=uitslagen'/>";
}
echo "</div>";
?>
 
             
            <?php 
include  ( "authorized.php" ) ; 
include  ( "../config/config.php" ) ; 
 
 
echo "<div id='main_border'>" ; echo "<table width='805' border='0'><tr class='blok2'><td>Uitslagen invoeren</td></tr></table><br />" ;  
echo "<table width='805px' class='blok3' border='0'><tr><td width='25'>id</td><td width='85'>Datum</td><td width='45'>Tijd</td><td width='50'>Nr.</td><td width='130' align='right'>Thuis</td><td width='10' align='center'></td><td width='180'>Uit</td><td width='140' align='center'>Uitslag</td><td width='140'></td></tr></table><br>" ;  
		$id  =  $row [ 'id' ] ; 
		$team  =  $row [ 'team' ] ; 
        $date  =  $row [ 'datum' ] ; 
        $time  =  $row [ 'tijd' ] ; 
		$nummer  =  $row [ 'wedstrijdnummer' ] ; 
        $thuis  =  $row [ 'thuis' ] ; 
        $uit  =  $row [ 'uit' ] ; 
        $score_thuis [ ]  =  $row [ 'score_thuis' ] ; 
        $score_uit [ ]  =  $row [ 'score_uit' ] ; 
		$tijd  =  cnv_tijd( $time ) ; 
		$datum  =  cnv_dat( $date ) ; 
 
echo "<form method='post' name='form'>" ; echo "<table width='805' border='0' class='hoofdtekst_2'><tr><td><input name='id[]' type='hidden' ></td><td width='25'>$id </td><td width='85'>$datum </td><td width='45'>$tijd </td><td width='50'>$nummer </td><td width='130' align='right'>$thuis </td><td width='10' align='center'>-</td><td width='180'>$uit </td><td width='65' align='right'><input name='score_thuis[]' type='text' style='width:30px' ></td><td width='10' align='center'>-</td><td width='65'><input name='score_uit[]' type='text' style='width:30px' ></td><td width='140'> </td></tr></table>" ; } 
echo "<table><td colspan='10'> </td></tr><tr><td></td><td valign='top' colspan='9'><input type='Submit' value='Uitslagen toevoegen'></td></tr></table> </form>" ; 
 
if ( $_SERVER [ 'REQUEST_METHOD' ]  ==  "POST" )  { 
for  ( $i = 0 ; $i < $count ; $i ++ ) { 
 
echo " score_thuis='" . $score_thuis [ $i ] . "', score_uit='" . $score_uit [ $i ] . "', id='" . $id [ $i ] . "';<br />" ; } 
//echo "<meta http-equiv='refresh' content='0;URL=index.php?location=uitslagen'/>"; 
} 
?> 
 
         
     
  
                      
                
                    
                         
                    
                    
                        
                            mwthomas                             
                         
                     
                    
                        Lid Zoals de foutmelding zegt: Je hebt als parameter een array ingegeven en geen string. 
                      
                
                    
                         
                    
                    
                        
                            Wijnand                             
                         
                     
                    
                        Moderator Oftewel niet om de array heen: 
                      
                
                    
                         
                    
                    
                        
                            Gezienus (laatste wijziging 08/07/2011 14:30)                             
                         
                     
                    
                        Lid Ik heb nu dat de velden in de database worden gevuld.
    
    
        
            
                if($_SERVER['REQUEST_METHOD'] == "POST") {
for ($i=0;$i<$count;$i++){
	$score_thuis = $_POST['score_thuis'];
    $score_uit = $_POST['score_uit'];
	$id = $_POST['id'];
	if (is_numeric($score_thuis));
	if (is_numeric($score_uit)) ;
	if (!empty($score_thuis));
	if (!empty($score_uit));
//$sql_update= mysql_query("UPDATE wedstrijden SET score_thuis='" . mysql_real_escape_string($score_thuis[$i]) . "', score_uit='" . mysql_real_escape_string($score_uit[$i]) . "' WHERE id='".$id[$i]."'") or trigger_error(mysql_error(),E_USER_ERROR);
echo "$count - ";
echo " score_thuis='".$score_thuis[$i]."', score_uit='".$score_uit[$i]."', id='".$id[$i]."';<br />";
} 
             
            if ( $_SERVER [ 'REQUEST_METHOD' ]  ==  "POST" )  { 
for  ( $i = 0 ; $i < $count ; $i ++ ) { 
	$score_thuis  =  $_POST [ 'score_thuis' ] ; 
    $score_uit  =  $_POST [ 'score_uit' ] ; 
	$id  =  $_POST [ 'id' ] ; 
	if  ( ! empty ( $score_thuis ) ) ;  //$sql_update= mysql_query("UPDATE wedstrijden SET score_thuis='" . mysql_real_escape_string($score_thuis[$i]) . "', score_uit='" . mysql_real_escape_string($score_uit[$i]) . "' WHERE id='".$id[$i]."'") or trigger_error(mysql_error(),E_USER_ERROR); 
echo " score_thuis='" . $score_thuis [ $i ] . "', score_uit='" . $score_uit [ $i ] . "', id='" . $id [ $i ] . "';<br />" ; } 
 
         
     
  
                      
                
                    
                         
                    
                        
		
		
	             
 
                
Je moet ingelogd  zijn om een reactie te kunnen posten.