Header error

Gestart doorBremdecoolste8 reacties52 weergaven

9 berichten · pagina 1 van 1

Bremdecoolste

Lid · Topicstarter

Berichten
1.783
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey,

Ik heb even een nieuw topic aangemaakt omdat ik en een nieuwe vraag had, en omdat die ndere een beetje te veel gespamt was (was vergeten in spoiler te zetten, dus de quotes zijn heel lang)

Dus nogmaals mijn vraag: Waarom krijg ik deze error:

Quote:
Warning: Cannot modify header information - headers already sent by (output started at C:xampphtdocsRegister.php:52) in C:xampphtdocsRegister.php on line 149
The field First Name is not posted

The field Last Name is not posted

You forgot to fill in your Gender

The field Birthday is not posted

The field Username is not posted

The field Email is not posted

The field Password is not posted

The field Confirm Password is not posted

The date is not valid
, ter wijl ik wel alles had ingevuld, en die header begrijp ik niet helemaal, in de lessen was het niet duidelijk uitgelegd dus heb maar wat geprobeerd...

Dit is mijn code:
Spoiler tonen
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html>
 <head>
  
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  
  <title>Register</title>
  
 </head>
 <body>
 <form method="post">
  <table width="30%">
  
  <tr>
   <td align="left" colspan="1"><i>First Name:</i></td>
   <td align="center" colspan="1"><input type="text" size="30" maxlength="13" name="firstname"></td>
  </tr>
  <tr>
   <td align="left" colspan="1"><i>Last name:</i></td>
   <td align="center" colspan="1"><input type="text" size="30" maxlength="20" name="lastname"></td>
  </tr> 
  <tr>
   <td align="left" colspan="1"><i>Gender:</i></td>
   <td align="center" colspan="1">
    <input type="radio" name="Gender" value="male">Male
    <input type="radio" name="Gender" value="female">Female
   </td>

  <tr>
   <td align="left" colspan="1"><i>Birthday:</i></td>
   <td align="center" colspan="1">
           <select name="Day"> 
            [COLOR= #0000BB]<?php[/COLOR] 
            [URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #0000BB]31[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++) 
            {[/COLOR] 
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<option value="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]">[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</option>[/COLOR][COLOR= #007700]; 
            }[/COLOR] 
            ?> 
        </select> 
        <select name="Month"> 
            [COLOR= #0000BB]<?php[/COLOR] 
            [URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #0000BB]12[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++) 
            {[/COLOR] 
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<option value="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]">[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</option>[/COLOR][COLOR= #007700]; 
            }[/COLOR] 
            ?> 
        </select> 
        <select name="Year"> 
            [COLOR= #0000BB]<?php[/COLOR] 
            [URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Y[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]>=[/COLOR] [COLOR= #0000BB]1950[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]--) 
            {[/COLOR] 
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<option value="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]">[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</option>[/COLOR][COLOR= #007700]; 
            }[/COLOR] 
            ?> 
        </select> 
   

   </td>
  </tr>   
   
  <tr>
   <td align="left" colspan="1"><i>Username:</i></td>
   <td align="center" colspan="1"><input type="text" size="30" maxlength="13" name="username"></td>
  </tr>
  <tr>
   <td align="left" colspan="1"><i>Email:</i></td>
   <td align="center" colspan="1"><input type="text" size="30" maxlength="45" name="mail"></td>
  </tr>
  <tr>
   <td align="left" colspan="1"><i>Password</i></td>
   <td align="center" colspan="1"><input type="password" size="30" maxlength="25" name="password"></td>
  </tr>
  <tr>
   <td align="left" colspan="1"><i>Confirm Password:</i></td>
   <td align="center" colspan="1"><input type="password" size="30"maxlength="25" name="passwordconfirm"></td>
  </tr>
  <tr>
    <td align="center" colspan="2"><input type="submit" value="Send"></td>
  </tr>
  
  </table>
 
 
  </form>

  [COLOR= #0000BB]<?php[/COLOR] 
  
[COLOR= #FF8000]// Is het verstuurd?[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]) 
{[/COLOR]
    [COLOR= #FF8000]// Voor opslag van errors en fouten[/COLOR]
    [COLOR= #0000BB]$Error[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR] 
    [COLOR= #0000BB]$Data[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR] 

    [COLOR= #FF8000]// Verplicht ingevuld te zijn[/COLOR]
    [COLOR= #0000BB]$RegisterFields[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR]
     [COLOR= #DD0000]First Name[/COLOR][COLOR= #007700],[/COLOR] 
     [COLOR= #DD0000]Last Name[/COLOR][COLOR= #007700],[/COLOR] 
     [COLOR= #DD0000]Gender[/COLOR][COLOR= #007700],[/COLOR] 
     [COLOR= #DD0000]Birthday[/COLOR][COLOR= #007700],[/COLOR] 
     [COLOR= #DD0000]Username[/COLOR][COLOR= #007700],[/COLOR] 
     [COLOR= #DD0000]Email[/COLOR][COLOR= #007700],[/COLOR] 
     [COLOR= #DD0000]Password[/COLOR][COLOR= #007700],[/COLOR] 
     [COLOR= #DD0000]Confirm Password[/COLOR][COLOR= #007700]);[/COLOR]

     [COLOR= #FF8000]// Velden bekijken[/COLOR]
     [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$RegisterFields[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$Field[/COLOR][COLOR= #007700]) 
     {[/COLOR]
            [COLOR= #FF8000]// Controleren of er een waarde is voor het veld[/COLOR]
            [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$Field[/COLOR][COLOR= #007700]]))
            {[/COLOR]
                  [COLOR= #FF8000]// Spaties weghalen[/COLOR]
                  [COLOR= #0000BB]$Value[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$Field[/COLOR][COLOR= #007700]]);[/COLOR]
     
                  [COLOR= #FF8000]// Controle of er iets is ingevuld[/COLOR]
                  [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$Value[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]);
                  {[/COLOR]
                     [COLOR= #FF8000]// Error[/COLOR]
                    [COLOR= #0000BB]$Error[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]You forgot to fill in your [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Field[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000][/COLOR][COLOR= #007700];
                  }[/COLOR]
     
                 [COLOR= #FF8000]// Ingevulde dingen toevoegen aan data[/COLOR]
                 [COLOR= #0000BB]$Data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$Field[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$Value[/COLOR][COLOR= #007700];
            }[/COLOR]
            [URL="http://www.php.net/else"]else[/URL]
           [COLOR= #007700]{[/COLOR]
                 [COLOR= #0000BB]$Error[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]The field [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Field[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] is not posted[/COLOR][COLOR= #007700];
           }
     }[/COLOR] 
    [COLOR= #FF8000]// Kijken of er geen grapjokers zijn, zoals Aarclay het noemt[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$Data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Month[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$Data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Day[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$Data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Year[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/checkdate"]checkdate[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$Data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Month[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$Data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Day[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$Data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Year[/COLOR][COLOR= #007700]])) 
    {[/COLOR] 
        [COLOR= #0000BB]$Date[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$Data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Day[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]-[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Month[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]-[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Year[/COLOR][COLOR= #007700]]; 
    }[/COLOR] 
    [URL="http://www.php.net/else"]else[/URL] 
    [COLOR= #007700]{[/COLOR] 
        [COLOR= #0000BB]$Error[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]The date is not valid[/COLOR][COLOR= #007700]; 
    }[/COLOR]  
  
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$Error[/COLOR][COLOR= #007700])) 
    {[/COLOR] 
         [COLOR= #FF8000]// Wat als de registratie succesvol is gegaan?[/COLOR]
         [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<p>You are now registered!</p>[/COLOR][COLOR= #007700]; 
    }[/COLOR] 
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
         [COLOR= #FF8000]// Wat als hij niet succesvol is gegaan?[/COLOR]
         [URL="http://www.php.net/ob_start"]ob_start[/URL][COLOR= #007700]();[/COLOR]
         [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Refresh: 3; url=Register.php[/COLOR][COLOR= #007700]);[/COLOR] 
         [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$Error[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$Error2[/COLOR][COLOR= #007700])
        {[/COLOR]
             [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<p>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Error2[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</p>[/COLOR][COLOR= #007700]; 
        } 
    }
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] 
[COLOR= #007700]{[/COLOR] 
    [COLOR= #FF8000]// Functies.php mag nog niet bezocht worden, terug naar het formulier [/COLOR]

[COLOR= #007700]}[/COLOR]

?>
  
 </body>
</html>
Alvast bedankt!

Mvg,
Bram.
0
Berichten
3.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Fix eerst die header error.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Er mag gewoonweg geen html voor je header stasn.
Ob_start() is ook niet een goede oplossing. De enige oplossing is door logisch te denken en eerst je header uitvoeren als het moet.
0
Berichten
3.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
laat maar, mijn fout
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Lol.... waarom session_start?
Weet je wel waar dat voor dient?
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je hebt in de array $RegisterFields de waarden van de tekst voor het input-field gezet. Je moet in die array de waarden van de names van die velden zetten. (bv: passwordconfirm ipv Confirm Password)
0
Bremdecoolste

Lid · Topicstarter

Berichten
1.783
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik moet dus eigenlijk het PHP script erboven zetten, boven de HTML form?
0
Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

Bremdecoolste schreef:
Ik moet dus eigenlijk het PHP script erboven zetten, boven de HTML form?
Lees goed wat die zegt. emo
0
Bremdecoolste

Lid · Topicstarter

Berichten
1.783
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Er mag gewoonweg geen html voor je header stasn.
Ob_start() is ook niet een goede oplossing. De enige oplossing is door logisch te denken en eerst je header uitvoeren als het moet.

Dat zei Rogier
toevoeging op 13 maart 2013, 161609:
Sjoerd schreef:
Je hebt in de array $RegisterFields de waarden van de tekst voor het input-field gezet. Je moet in die array de waarden van de names van die velden zetten. (bv: passwordconfirm ipv Confirm Password)

Ik heb nu
Quote:
$RegisterFields = array(
firstname,
lastname,
gender,
day,
username,
mail,
password,
passwordconfirm);
,
Maar nog steeds komt er steeds: "You forgot to fill in your lastname? De names van het formulier heb ik toch precies hierin gezet?
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren