Jump to content

senca99

Members
  • Posts

    40
  • Joined

  • Last visited

Everything posted by senca99

  1. Thank you for your reply. That was the method I had in my head to but it looks so unsafe to me. Is there any way to overcome this? A safer way only using php and mysql? When I think about it I can't see any other way than the traditional one. Even with the use of Joomla, WordPress,... there still has to be a loginform and a database so doesn't that mean this also is the traditional way of doing things?
  2. Hey, I was having some trouble in finding the logic in this: I have a login form (php) and a mySQL database storing the username and password. Problem is that my database is also protected because logically you don't want username's and/or passwords to be public. This means that when someone tries the login form, it is impossible to check if he has correct credentials because this would imply that the db password should be used also to grant access to the database. How to overcome this issue?
  3. I am sorry for not including the file names. The first file is registratie_gezin_kids.php The second one is a php file containing some functions (like the form) called functies_voor_registraties.php The third page is registratie_gezin.php registratie_gezin_kids.php lets you select the amout of children you have. It is the first page that is shown. After submitting, you get redirected towards registratie_gezin.php where you will get the form that is inside functies_voor_registraties.php. I hope this makes it a bit clearer? edit: I tried testing every input with isset() but it then jumps immediately to the else structure instead of showing the form in the if part.
  4. Hey, I have a first php page containing a dropdown menu form. Submitting this form redirects to a new php page containing a bigger form with input fields. This form works as a charm when the page is loaded (without a submit e.a.) but when redirected the checks on this form are done immediatelly with the result that when you proceed to this page, all the errors are there which is not the idea. How can I make the errors dissapear until a first submit of this second form? I've been trying with submit check and isset but that iliminates my errors and doesn't show them anymore. first page(the small drop down menu form which will redirect to the bigger form): <?php include("header.php"); include("functies_voor_registraties.php"); echo '<p>Gelieve eerst hieronder het aantal kinderen te selecteren:</p>'; echo' <form method="post" action="registratie_gezin.php"> <p>Ik heb: <br /> <select name="aantalkids" id="aantalkids"> <option value=1 $een>1 kind</option> <option value=2 $twee>2 kinderen</option> <option value=3 $twee>3 kinderen</option> <option value=4 $twee>4 kinderen</option> <option value=5 $twee>5 kinderen</option> </select> </p> <p> '; form_knoppen(); include("footer.php"); ?> 2nd page(the actual big form which will be called at the 3rd page: see below): <?php function algemeen_registratie_formulier() { echo'<p>Registreer</p>'; $familienaam=''; $voornaam=''; $straat=''; $huisnr=''; $postcode=''; $plaats=''; $mail=''; $telnr=''; $paswoord=''; $bijzonderh=''; $aantalkids=''; // Speciale checks voor familienaam,voornaam,straat,plaats en e-mailadres wordt gedaan als we het form submitten if ($_SERVER['REQUEST_METHOD'] == 'POST') { if(isset($_POST['naam'])){ $familienaam=$_POST['naam'];} if(isset($_POST['vnaam'])){ $voornaam=$_POST['vnaam'];} if(isset($_POST['straat'])){ $straat=$_POST['straat'];} if(isset($_POST['huisnr'])){ $huisnr=$_POST['huisnr'];} if(isset($_POST['postcode'])){ $postcode=$_POST['postcode'];} if(isset($_POST['plaats'])){ $plaats=$_POST['plaats'];} if(isset($_POST['mail'])){ $mail=$_POST['mail'];} if(isset($_POST['telnr'])){ $telnr=$_POST['telnr'];} if(isset($_POST['paswoord'])){ $paswoord=$_POST['paswoord'];} $bijzonderh= $_POST['bijzonderh']; /*Hieronder de regexen om de input te verifiëren*/ if (!ereg('^[ a-zA-Z-]+$', $_POST['naam'])){ $familienaam_fout = 1;} if (!ereg('^[ a-zA-Z-]+$', $voornaam)){ $voornaam_fout = 1;} if (!ereg('^[ a-zA-Z-]+$', $straat)){ $straat_fout = 1;} if (!ereg("/^[0-9]{1,3}[a-z]{0,1}$/i", $huisnr)){ $huisnr_fout = 1;} if (!ereg('^[1-9][0-9]{3}$', $postcode)){ $postcode_fout = 1;} if (!ereg('^[ a-zA-Z-]+$', $plaats)) $plaats_fout = 1; if (function_exists('filter_var') && !filter_var($mail, FILTER_VALIDATE_EMAIL)) $email_fout = 1; if (!ereg('^0[1-9][0-9]{7}$', $telnr)) $telnr_fout = 1; if (!ereg('^[a-zA-Z0-9]+$', $paswoord)) $paswoord_fout = 1; if (!empty($_POST['bijzonderh'])){ if(!ereg('^\W+', $bijzonderh)){ $bijzonderh_fout = 1; } } $bijzonderh_fout = 1; } // Kijk of alle velden zijn ingevuld - //voornaam en familienaam,straat en plaats mag alleen uit letters bestaan //en het e-mailadres moet juist zijn...wordt gechecked bij submit if (($_SERVER['REQUEST_METHOD'] == 'POST' && (empty($_POST['naam']) || !empty($familienaam_fout) || empty($_POST['vnaam']) || !empty($voornaam_fout)|| empty($_POST['straat']) || !empty($straat_fout) || empty($_POST['postcode']) || !empty($postcode_fout) || empty($_POST['telnr']) || !empty($telnr_fout) || empty($_POST['plaats']) || !empty($plaats_fout) || empty($_POST['mail']) || !empty($email_fout))) || $_SERVER['REQUEST_METHOD'] == 'GET') { if (!empty($voornaam_fout)) echo '<p>U vulde geen of een foute voornaam in.</p>'; if (!empty($familienaam_fout)) echo '<p>U vulde geen of een foute familienaam in.</p>'; if (!empty($straat_fout)) echo '<p>U vulde geen of een foute straatnaam in.</p>'; if (!empty($huisnr_fout)) echo '<p>U vulde een ongeldig huisnummer in.</p>'; if (!empty($postcode_fout)) echo '<p>Uw postcode mag enkel uit 4 cijfers bestaan.</p>'; if (!empty($plaats_fout)) echo '<p>U vulde geen plaats in.</p>'; if (!empty($email_fout)) echo '<p>U vulde geen e-mail adres in.</p>'; if (!empty($telnr_fout)) echo '<p>U vulde een ongeldig telefoonnummer in (enkel 9 cijfers toegestaan).</p>'; if (!empty($paswoord_fout)) echo '<p>Een paswoord moet minstens 1 hoofdletter bevatten en mintens 1 cijfer en mag GEEN speciale tekens bevatten.</p>'; if (!empty($bijzonderh_fout)) echo '<p>U koos ervoor een optionele mededeling te plaatsen maar het is nie just!</p>'; echo' <form method="post" action="' . $_SERVER['REQUEST_URI'] . '"> <p>Vul je voornaam in: <br /> <input type="text" value="' .$voornaam. '" name="vnaam" /> </p> <p>Vul je naam in: <br /> <input type="text" value="' .$familienaam. '" name="naam" /> </p> <p>Straat: <br /> <input type="text" value="' .$straat. '" name="straat" /> </p> <p>Huisnummer: <br /> <input type="text" value="' .$huisnr. '" name="huisnr" /> </p> <p>Postcode: <br /> <input type="text" value="' .$postcode. '" name="postcode" /> </p> <p>Stad: <br /> <input type="text" value="' .$plaats. '" name="plaats" /> </p> <p>E-mail: <br /> <input type="text" value="' .$mail. '" name="mail" /> </p> <p>TELnr(enkel cijfers!): <br /> <input type="text" value="' .$telnr. '" name="telnr" /> </p> <p>Paswoord(minstens 1 hoofdletter, 1 cijfer en GEEN speciale tekens: <br /> <input type="text" value="' .$paswoord. '" name="paswoord" /> </p> <p>*Opmerkingen of bijzonderheden: <br /> <input type="text" value="' .$bijzonderh. '" name="bijzonderh" /> </p> </p> '; } else{ $current_url = $_SERVER['PHP_SELF']; if($current_url == "/tweedekans/registratie_gezin.php"){ echo' U heeft zich geregistreerd met de volgende gegevens: Naam + voornaam: '; echo $familienaam, $voornaam; echo'Adres: '; echo $straat, $huisnr, $postcode, $plaats; echo' <p>Vul hieronder de namen en geboortedata van uw kinderen in:</p> '; $times=$_POST['aantalkids']; $kind1=''; $kind2=''; $kind3=''; $kind4=''; $kind5=''; $devalues = array(1 => $kind1, 2 => $kind2, 3 => $kind3, 4 => $kind4, 5 => $kind5); echo ' <form method="post" action="' . $_SERVER['REQUEST_URI'] . '"> '; for($i=1; $i<=$times; $i++) { echo ' <p>Naam '; echo $i; echo 'e kind: <br /> <input type="text" value="' .$devalues[$i]. ' " name="naamkind'.$i.'" /> </p> '; } } else{ echo 'here the form will be handled for DB and stuff...' } } } function form_knoppen(){ echo' <p> <input type="submit" value="Verzenden" /> <input type="reset" value="Wissen" /> </p> </form>'; } ?> The next code is the second page where the bigger form will be called: <?php include("header.php"); include("functies_voor_registraties.php"); algemeen_registratie_formulier(); form_knoppen(); include("footer.php"); ?>
  5. Does any one know if there is a possibility to ignore the first form when it is correctly submitted? I still don't get why at first you can submit the first form and the right values are remembered until a correct form submission is done, but from the moment you get to a second form, the form data from the first one still exist but aren't filled in in the form anymore. :s. The code: <?php function algemeen_registratie_formulier($familienaam,$voornaam,$straat,$huisnr,$postcode,$plaats,$mail,$telnr,$paswoord,$bijzonderh,$aantalkids) { $check=0; echo'<p>Registreer</p>'; $familienaam=''; $voornaam=''; $straat=''; $huisnr=''; $postcode=''; $plaats=''; $mail=''; $telnr=''; $paswoord=''; $bijzonderh=''; $aantalkids=''; // Speciale checks voor familienaam,voornaam,straat,plaats en e-mailadres wordt gedaan als we het form submitten if ($_SERVER['REQUEST_METHOD'] == 'POST') { $familienaam=$_POST['naam']; $voornaam=$_POST['vnaam']; $straat=$_POST['straat']; $huisnr=$_POST['huisnr']; $postcode=$_POST['postcode']; $plaats=$_POST['plaats']; $mail=$_POST['mail']; $telnr=$_POST['telnr']; $paswoord=$_POST['paswoord']; $bijzonderh= $_POST['bijzonderh']; /*Hieronder de regexen om de input te verifiëren*/ if (!ereg('^[ a-zA-Z-]+$', $_POST['naam'])){ $familienaam_fout = 1;} if (!ereg('^[ a-zA-Z-]+$', $_POST['vnaam'])){ $voornaam_fout = 1;} if (!ereg('^[ a-zA-Z-]+$', $_POST['straat'])){ $straat_fout = 1;} if (!ereg("/^[0-9]{1,3}[a-z]{0,1}$/i", $_POST['huisnr'])){ $huisnr_fout = 1;} if (!ereg('^[1-9][0-9]{3}$', $_POST['postcode'])){ $postcode_fout = 1;} if (!ereg('^[ a-zA-Z-]+$', $_POST['plaats'])) $plaats_fout = 1; if (function_exists('filter_var') && !filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL)) $email_fout = 1; if (!ereg('^0[1-9][0-9]{7}$', $_POST['telnr'])) $telnr_fout = 1; if (!ereg('^[a-zA-Z0-9]+$', $_POST['paswoord'])) $paswoord_fout = 1; if (!empty($_POST['bijzonderh'])){ if(!ereg('^\W+', $_POST['bijzonderh'])){ $bijzonderh_fout = 1; } } $bijzonderh_fout = 1; } // Kijk of alle velden zijn ingevuld - //voornaam en familienaam,straat en plaats mag alleen uit letters bestaan //en het e-mailadres moet juist zijn...wordt gechecked bij submit if (($_SERVER['REQUEST_METHOD'] == 'POST' && (empty($_POST['naam']) || !empty($familienaam_fout) || empty($_POST['vnaam']) || !empty($voornaam_fout)|| empty($_POST['straat']) || !empty($straat_fout) || empty($_POST['postcode']) || !empty($postcode_fout) || empty($_POST['telnr']) || !empty($telnr_fout) || empty($_POST['plaats']) || !empty($plaats_fout) || empty($_POST['mail']) || !empty($email_fout))) || $_SERVER['REQUEST_METHOD'] == 'GET') { if (!empty($voornaam_fout)) echo '<p>U vulde geen of een foute voornaam in.</p>'; if (!empty($familienaam_fout)) echo '<p>U vulde geen of een foute familienaam in.</p>'; if (!empty($straat_fout)) echo '<p>U vulde geen of een foute straatnaam in.</p>'; if (!empty($huisnr_fout)) echo '<p>U vulde een ongeldig huisnummer in.</p>'; if (!empty($postcode_fout)) echo '<p>Uw postcode mag enkel uit 4 cijfers bestaan.</p>'; if (!empty($plaats_fout)) echo '<p>U vulde geen plaats in.</p>'; if (!empty($email_fout)) echo '<p>U vulde geen e-mail adres in.</p>'; if (!empty($telnr_fout)) echo '<p>U vulde een ongeldig telefoonnummer in (enkel 9 cijfers toegestaan).</p>'; if (!empty($paswoord_fout)) echo '<p>Een paswoord moet minstens 1 hoofdletter bevatten en mintens 1 cijfer en mag GEEN speciale tekens bevatten.</p>'; if (!empty($bijzonderh_fout)) echo '<p>U koos ervoor een optionele mededeling te plaatsen maar het is nie just!</p>'; echo' <form method="post" action="' . $_SERVER['REQUEST_URI'] . '"> <p>Vul je voornaam in: <br /> <input type="text" value="' .$voornaam. '" name="vnaam" /> </p> <p>Vul je naam in: <br /> <input type="text" value="' .$familienaam. '" name="naam" /> </p> <p>Straat: <br /> <input type="text" value="' .$straat. '" name="straat" /> </p> <p>Huisnummer: <br /> <input type="text" value="' .$huisnr. '" name="huisnr" /> </p> <p>Postcode: <br /> <input type="text" value="' .$postcode. '" name="postcode" /> </p> <p>Stad: <br /> <input type="text" value="' .$plaats. '" name="plaats" /> </p> <p>E-mail: <br /> <input type="text" value="' .$mail. '" name="mail" /> </p> <p>TELnr(enkel cijfers!): <br /> <input type="text" value="' .$telnr. '" name="telnr" /> </p> <p>Paswoord(minstens 1 hoofdletter, 1 cijfer en GEEN speciale tekens: <br /> <input type="text" value="' .$paswoord. '" name="paswoord" /> </p> <p>*Opmerkingen of bijzonderheden: <br /> <input type="text" value="' .$bijzonderh. '" name="bijzonderh" /> </p> </p> '; $current_url = $_SERVER['PHP_SELF']; if($current_url == "/tweedekans/registratie_gezin.php"){ kies_aantal_kids(); } } else{ $current_url = $_SERVER['PHP_SELF']; if($current_url == "/tweedekans/registratie_gezin.php"){ echo' U heeft zich geregistreerd met de volgende gegevens: Naam + voornaam: '; echo $naam, $voornaam; echo'Adres: '; echo $straat, $huisnr, $postcode, $plaats; echo' <p>Vul hieronder de namen en geboortedata van uw kinderen in:</p> '; $times=$_POST['aantalkids']; $kind1=''; $kind2=''; $kind3=''; $kind4=''; $kind5=''; $devalues = array(1 => $kind1, 2 => $kind2, 3 => $kind3, 4 => $kind4, 5 => $kind5); echo ' <form method="post" action="' . $_SERVER['REQUEST_URI'] . '"> '; for($i=1; $i<=$times; $i++) { echo ' <p>Naam '; echo $i; echo 'e kind: <br /> <input type="text" value="' .$devalues[$i]. ' " name="naamkind'.$i.'" /> </p> '; } } else{ echo 'Beste babysitter, u registratie zal nu afgehandelt worden!'; } } } function form_knoppen(){ echo' <p> <input type="submit" value="Verzenden" /> <input type="reset" value="Wissen" /> </p> </form>'; } function kies_aantal_kids(){ echo' <p>Ik heb: <br /> <select name="aantalkids" id="aantalkids"> <option value=1 $een>1 kind</option> <option value=2 $twee>2 kinderen</option> <option value=3 $twee>3 kinderen</option> <option value=4 $twee>4 kinderen</option> <option value=5 $twee>5 kinderen</option> </select> </p> '; } ?>
  6. One big problem...the second form comes up the way it should BUT! the form header is again reguest_uri because this form has to be checked for errors as well but this means that on submitting the second form for checks the whole php page is being reloaded including the first form and not the second one. :s. What a bummer :s
  7. To clarify myself: When submitting a correct form (when you reach the else), a new miniform will appear. How many fields it will show depends on a dropdown menu in the first form. Also the other form values(from the first form) are used after the second form is filled in. Everything from form 1 and 2 will be stored in database. I thought that when the first form was filled in correctly and you went to the second form, that the values of the first form would be lost. But apparently they aren't because I just checked and it worked. I don't get it, how is it possible to retrieve my data after the form is submitted?
  8. Hey all! I'm kinda stuck on this one. I've got a form with checks in a function. But when the form is filled in correctly I wan't to retrieve its data but is that possible? In pseudocode it looks like this: if(form isn't filled in correctly){ show the form again } else{ use the values for something else } The form action is a $_SERVER['request_uri'] . Which means that when reaching the 'else' I'm still on the same page but I need to retrieve the form data. Could someone point me in the right direction and is that even possible?
  9. Sorry for the late reply, I totally lost trach of this one! I tried what you said but I still get the notices. I changed the functionheader like this: function algemeen_registratie_formulier($familienaam,$voornaam,$straat,$huisnr,$postcode,$plaats,$mail,$telnr,$paswoord,$bijzonderh,$aantalkids) and I referenced them: algemeen_registratie_formulier(&$familienaam,&$voornaam,&$straat,&$huisnr,&$postcode,&$plaats,&$mail,&$telnr,&$paswoord,&$bijzonderh,&$aantalkids); Does it have something to do with the fact that the page is reloaded before showing the form? I first show a dropdown menu and when submitting the choice, the function is called and shows the form.
  10. Sorry if I wasn't clear. The line I gave was kindoff a pseudoregex. The bottomline is that it has to check for one of 6 possible combinations. For instance a person could live at number 66. The regex should check wether it is a valid housenumber according to the 6 possible combinations of ints and a char I gave. Thats why I used OR's to try and clearify what I ment. I guess in ugly terms that would give a pseudoregex like this: ^[1-9]$ OR ^[1-9][0-9]$ OR ^[1-9][0-9]{2}$ OR ^[1-9][A-Za-z]$ OR ^[1-9][0-9][A-Za-z]$ OR ^[1-9][0-9]{2}[A-Za-Z]$ I'm hoping that makes it more clear.
  11. Thats not quite what I ment. The user input is only one of the 6 possibilities. They don't have to be what I wrote down but it just has to be int(s) that can be followed by a char. The user input is a housenumber. That could be any of the 6 combinations I wrote down. Characters stands for the mailbox number in flats.
  12. Hey everyone! I can do some basic regexing but I don't really have a clue for this one. I want to create a regex that checks a user inputfield and it can only be this: 4 34 535 4a 55C 997G Only these 6 matches, an int, 2 ints, 3 ints, 1 int and a char, 2 ints and a char or 3 ints and a char. Not minding caps but it cannot be more then these 6. Something like "anintORtwointsORthreeintsORoneintandacharOR..." you get the point . The OR's are bugging me because I can't find a single line regex for it. Can anyone help me out?
  13. Hey all! I've written code for checking form input and it works fine if its just a php script. But for OO reasons I wanted to put the code in a function. But when calling the function in a different script suddenly I get notices that my variables in the function are undefined. :s Does anyone know why? This is the function code: function algemeen_registratie_formulier() { echo'<p>Registreer</p>'; $familienaam=''; $voornaam=''; $straat=''; $huisnr=''; $postcode=''; $plaats=''; $mail=''; $telnr=''; $bijzonderh=''; $aantalkids=''; // Speciale checks voor familienaam,voornaam,straat,plaats en e-mailadres wordt gedaan als we het form submitten if ($_SERVER['REQUEST_METHOD'] == 'POST') { $familienaam=$_POST['naam']; $voornaam=$_POST['vnaam']; $straat=$_POST['straat']; $huisnr=$_POST['huisnr']; $postcode=$_POST['postcode']; $plaats=$_POST['plaats']; $mail=$_POST['mail']; $telnr=$_POST['telnr']; $bijzonderh= $_POST['bijzonderh']; /*Hieronder de regexen om de input te verifiëren*/ if (!ereg('^[ a-zA-Z-]+$', $_POST['naam'])){ $familienaam_fout = 1;} if (!ereg('^[ a-zA-Z-]+$', $_POST['vnaam'])){ $voornaam_fout = 1;} if (!ereg('^[ a-zA-Z-]+$', $_POST['straat'])){ $straat_fout = 1;} if ((!ereg('[1-9][A-Za-z]',$_POST['huisnr'])) && (!ereg('[1-9][0-9]{3}', $_POST['huisnr']))){ $huisnr_fout = 1;} if (!ereg('^[1-9][0-9]{3}$', $_POST['postcode'])){ $postcode_fout = 1;} if (!ereg('^[ a-zA-Z-]+$', $_POST['plaats'])) $plaats_fout = 1; if (function_exists('filter_var') && !filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL)) $email_fout = 1; if (!ereg('^0[1-9][0-9]{7}$', $_POST['telnr'])) $telnr_fout = 1; /* if (!empty($_POST['bijzonderh'])){ if(){ } } $bijzonderh_fout = 1; */ } // Kijk of alle velden zijn ingevuld - //voornaam en familienaam,straat en plaats mag alleen uit letters bestaan //en het e-mailadres moet juist zijn...wordt gechecked bij submit if (($_SERVER['REQUEST_METHOD'] == 'POST' && (empty($_POST['naam']) || !empty($familienaam_fout) || empty($_POST['vnaam']) || !empty($voornaam_fout)|| empty($_POST['straat']) || !empty($straat_fout) || empty($_POST['postcode']) || !empty($postcode_fout) || empty($_POST['telnr']) || !empty($telnr_fout) || empty($_POST['plaats']) || !empty($plaats_fout) || empty($_POST['mail']) || !empty($email_fout))) || $_SERVER['REQUEST_METHOD'] == 'GET') { if (!empty($voornaam_fout)) echo '<p>U vulde geen of een foute voornaam in.</p>'; if (!empty($familienaam_fout)) echo '<p>U vulde geen of een foute familienaam in.</p>'; if (!empty($straat_fout)) echo '<p>U vulde geen of een foute straatnaam in.</p>'; if (!empty($huisnr_fout)) echo '<p>U vulde een ongeldig huisnummer in.</p>'; if (!empty($postcode_fout)) echo '<p>Uw postcode mag enkel uit 4 cijfers bestaan.</p>'; if (!empty($plaats_fout)) echo '<p>U vulde geen plaats in.</p>'; if (!empty($email_fout)) echo '<p>U vulde geen e-mail adres in.</p>'; if (!empty($telnr_fout)) echo '<p>U vulde een ongeldig telefoonnummer in (enkel 9 cijfers toegestaan).</p>'; if (!empty($bijzonderh_fout)) echo '<p>U vulde een ongeldig telefoonnummer in (enkel 9 cijfers toegestaan).</p>'; echo' <form method="post" action="' . $_SERVER['REQUEST_URI'] . '"> <p>Vul je voornaam in: <br /> <input type="text" value="' .$voornaam. '" name="vnaam" /> </p> <p>Vul je naam in: <br /> <input type="text" value="' .$familienaam. '" name="naam" /> </p> <p>Straat: <br /> <input type="text" value="' .$straat. '" name="straat" /> </p> <p>Huisnummer: <br /> <input type="text" value="' .$huisnr. '" name="huisnr" /> </p> <p>Postcode: <br /> <input type="text" value="' .$postcode. '" name="postcode" /> </p> <p>Stad: <br /> <input type="text" value="' .$plaats. '" name="plaats" /> </p> <p>E-mail: <br /> <input type="text" value="' .$mail. '" name="mail" /> </p> <p>TELnr(enkel cijfers!): <br /> <input type="text" value="' .$telnr. '" name="telnr" /> </p> <p>*Opmerkingen of bijzonderheden: <br /> <input type="text" value="' .$bijzonderh. '" name="bijzonderh" /> </p> </p> <input type="submit" value="Verzenden" /> <input type="reset" value="Wissen" /> </p> </form>'; } /*Deze else zal worden uitgevoerd bij een correcte input in het basis registratieformulier*/ else{ /*eerste check==> een gezin registreerd==>selecteer aantal kinderen*/ if($_POST['registratiekeuze'] == 'babysit'){ print "U heeft zich geregistreerd als babysit. U registratie wordt afgehandelt."; } else{ echo' <form method="post" action="registreeraantalkids.php"> <p>Ik ben: <br /> <select name="registratiekeuze" id="registratiekeuze"> <option value=1 $een>1 kind</option> <option value=2 $twee>2 kinderen</option> <option value=3 $twee>3 kinderen</option> <option value=4 $twee>4 kinderen</option> <option value=5 $twee>5 kinderen</option> </select> <input type="submit" value="Ga verder..." /> </form> '; } } } The code calling the function: include("functies_voor_registraties.php"); $keuze=globale_keuze(); if($keuze=='gezin'){ algemeen_registratie_formulier(); } elseif($keuze=='babysit') { echo' <p>Registratie voor babysitter:</p>'; algemeen_registratie_formulier(); }
  14. Sorry for the late reply, I wasn't tracking this thread by e-mail (which I thought I did). Thank you for the help, I will try it!
  15. I would like to change my displayname to senca99
  16. Hey y'all! I was writing a simple registrationform with some checks in it. I made a main registration page and a page with 3 functions ==> show_registration_form, process_registration_form and validate_registration_form. The page displays well until I click on the submit button. For some reason, wether the input is correct or not, I get a 404 because you get linked to an unexisting link but I don't know why. The regular url is this: somethin.be/tweedekans/registreer.php but when submitting the url changes to this: somethin.be/tweedekans/' . /tweedekans/registreer.php . ' with the magical allknown message: The requested URL /tweedekans/' . /tweedekans/registreer.php . ' was not found on this server. The 2 files are both located in the same directory on the server. Why is this happening? This is the code in the main page: <?php include("header.php"); include("functions_for_registration.php"); echo'<p>Registreer</p>'; if(isset($_POST['_submit_check'])) { if($form_errors = validate_registration_form()) { show_registration_form($form_errors); } else { process_registration_form(); } } else { show_registration_form(); } include("footer.php"); ?> And these are the functions: <?php function show_registration_form($errors = ''){ if(isset($_POST['_submit_check'])) { $defaults = $_POST; } if($errors) { $error_text = '<tr><td>you need to correct the following errors:'; $error_text .= '</td><td><ul><li>'; $error_text .= implode('</li><li>', $errors); $error_text .= '</li></ul></td></tr>'; } else { $error_text = ''; } /* Initialisatie van de vars */ $voornaam=""; $familienaam=""; $straat=""; $huisnr=""; $postcode=""; $plaats=""; $mail=""; $telnr=""; $bijzonderheden=""; /* De code voor het inschrijvingsformulier */ print<<<_HTML_ <form method="post" action="' . $_SERVER[php_SELF] . '"> <p>Vul je voornaam in: <br /> <input type="text" value="' .$voornaam. '" name="vnaam" /> </p> <p>Vul je naam in: <br /> <input type="text" value="' .$familienaam. '" name="naam" /> </p> <p>Straat: <br /> <input type="text" value="' .$straat. '" name="straat" /> </p> <p>Huisnummer: <br /> <input type="text" value="' .$huisnr. '" name="huisnr" /> </p> <p>Postcode: <br /> <input type="text" value="' .$postcode. '" name="postcode" /> </p> <p>Stad: <br /> <input type="text" value="' .$plaats. '" name="plaats" /> </p> <p>E-mail: <br /> <input type="text" value="' .$mail. '" name="mail" /> </p> <p>TELnr(enkel cijfers!): <br /> <input type="text" value="' .$telnr. '" name="telnr" /> </p> <p>Extra opmerkingen?: <br /> <input type="text" value="' .$bijzonderheden. '" name="bijzonderh" /> </p> </p> <input type="submit" value="Verzenden" /> <input type="reset" value="Wissen" /> </p> </form> _HTML_; } function validate_registration_form(){ $errors = array(); if(empty($POST['vnaam'])){ $errors[] = 'U vergat een voornaam in te vullen'; } if(empty($POST['naam'])){ $errors[] = 'U vergat een familienaam in te vullen'; } if(empty($POST['straat'])){ $errors[] = 'U vergat een straatnaam in te vullen'; } if(empty($POST['huisnr'])){ $errors[] = 'U vergat een huisnummer in te vullen'; } if(empty($POST['plaats'])){ $errors[] = 'U vergat een woonplaats in te vullen'; } if(empty($POST['mail'])){ $errors[] = 'U vergat een e-mailadres in te vullen'; } if(empty($POST['telnr'])){ $errors[] = 'U vergat een telefoonnummer in te vullen'; } return $errors; } function process_registration_form(){ print 'Dit formulier is geslaagd voor de test!'; } ?>
  17. I've pasted the contactpage code because I don't know how to 'fix' it. The thank you message is shown inside the div where the form was present, just to give some info. <?php include('header.php'); ?> <div id="contentainer"> <div id="linkerbalk"> </div> <div id="content"> <br /> <h1>Contacteer ons</h1> <p> Kinder-en jeugdschoenen Indy<br /> Postweg 126 B1<br /> 1602 Vlezenbeek<br /> Tel: 0032/02/460.22.60<br /><br /> Voor vragen of opmerkingen kan u onderstaand contactformulier invullen. Een kopie zal naar uw e-mailadres gestuurd worden. </p> <table> <tr> <td> <?php $naam=''; $vnaam=''; $mail=''; $onderwerp=''; $bericht= ''; $mail_ontv = 'svensegers88@gmail.com'; // Speciale checks voor naam en e-mailadres wordt gedaan als we het form submitten if ($_SERVER['REQUEST_METHOD'] == 'POST') { $naam=$_POST['naam']; $vnaam=$_POST['vnaam']; $mail=$_POST['mail']; $onderwerp=$_POST['onderwerp']; $bericht= $_POST['bericht']; // naam controle if (!ereg('^[ a-zA-Z-]+$', $_POST['naam'])) $naam_fout = 1; // voornaam controle if (!ereg('^[ a-zA-Z-]+$', $_POST['vnaam'])) $vnaam_fout = 1; // e-mail controle if (function_exists('filter_var') && !filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL)) $email_fout = 1; // onderwerp controle if (!ereg('^[ a-zA-Z-]+$', $_POST['onderwerp'])) $onderwerp_fout = 1; // bericht controle if (strlen($bericht )<20) $bericht_fout = 1; // antiflood controle if (!empty($_SESSION['antiflood'])) { $seconde = 20; // 20 seconden voordat dezelfde persoon nog een keer een e-mail mag versturen $tijd = time() - $_SESSION['antiflood']; if($tijd < $seconde) $antiflood = 1; } } $naamerror=''; $vnaamerror=''; $mailerror=''; $onderwerperror=''; $berichterror=''; // Kijk of alle velden zijn ingevuld - naam mag alleen uit letters bestaan en het e-mailadres moet juist zijn, wordt gedaan als er op submit geklikt word if (($_SERVER['REQUEST_METHOD'] == 'POST' && (!empty($antiflood) || empty($_POST['naam']) || !empty($naam_fout) || empty($_POST['vnaam']) || !empty($vnaam_fout) || empty($_POST['mail']) || !empty($email_fout) || empty($_POST['onderwerp']) || !empty($onderwerp_fout) || empty($_POST['bericht']) || !empty($bericht_fout))) || $_SERVER['REQUEST_METHOD'] == 'GET') { if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!empty($naam_fout)) $naamerror='<tr><td></td><td><img src="warning.png" alt="warning" width=12 height=12 /> <font size = 3px>U vulde geen of een foute naam in</font></td></tr>'; if (!empty($vnaam_fout)) $vnaamerror='<tr><td></td><td><img src="warning.png" alt="warning" width=12 height=12 /> <font size = 3px>U vulde geen of een foute voornaam in</font></td></tr>'; if (!empty($email_fout)) $mailerror='<tr><td></td><td><img src="warning.png" alt="warning" width=12 height=12 /> <font size = 3px> U vulde geen of een onjuist e-mail adres in</font></td></tr>'; if (!empty($onderwerp_fout)) $onderwerperror='<tr><td></td><td><img src="warning.png" alt="warning" width=12 height=12 /> <font size = 3px>U vulde geen onderwerp in</font></td></tr>'; if (!empty($bericht_fout)) $berichterror='<tr><td></td><td><img src="warning.png" alt="warning" width=12 height=12 /> <font size = 3px>U vulde geen bericht in</font></td></tr>'; } // HTML e-mail formlier echo '<form method="post" action="' .$_SERVER['REQUEST_URI'] . '" /> <table> '.$naamerror.' <tr><td><label for="naam" font-family="Monotype Corsiva">Naam:</label></td> <td><input type="text" size=40 id="naam" name="naam" value="' .$naam. '" /></td></tr> '.$vnaamerror.' <tr><td><label for="voornaam">Voornaam:</label></td> <td><input type="text" size=40 id="vnaam" name="vnaam" value="' .$vnaam. '" /><td></tr> '.$mailerror.' <tr><td><label for="mail">E-mailadres:</label></td> <td><input type="text" size=40 id="mail" name="mail" value="' . $mail . '" /></td></tr> '.$onderwerperror.' <tr><td><label for="onderwerp">Onderwerp:</label></td> <td><input type="text" size=40 id="onderwerp" name="onderwerp" value="' . $onderwerp . '" /></td></tr> '.$berichterror.' <td><label for="bericht">Bericht:</label></td> <td><textarea id="bericht" name="bericht" rows="8" style="width: 340px;">' . $bericht . '</textarea></td> <tr><td></td><td><input type="submit" name="submit" value=" Versturen " /></td></tr> </table> </form>'; } // versturen naar else { // set datum $datum = date('d/m/Y H:i:s'); $inhoud_mail = "===================================================\n"; $inhoud_mail .= "Ingevulde contact formulier " . $_SERVER['HTTP_HOST'] . "\n"; $inhoud_mail .= "===================================================\n\n"; $inhoud_mail .= "Naam: " . htmlspecialchars($_POST['naam']) . "\n"; $inhoud_mail .= "Voornaam: " . htmlspecialchars($_POST['vnaam']) . "\n"; $inhoud_mail .= "E-mail adres: " . htmlspecialchars($_POST['mail']) . "\n"; $inhoud_mail .= "Bericht:\n"; $inhoud_mail .= htmlspecialchars($_POST['bericht']) . "\n\n"; $inhoud_mail .= "===================================================\n\n"; // -------------------- // spambot protectie $headers = 'From: ' . htmlspecialchars($_POST['naam']) . htmlspecialchars($_POST['vnaam']) . ' <' . $_POST['mail'] . '>'; $headers = stripslashes($headers); $headers = str_replace('\n', '', $headers); // Verwijder \n $headers = str_replace('\r', '', $headers); // Verwijder \r $headers = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $headers)); // Slashes van quotes $_POST['onderwerp'] = str_replace('\n', '', $_POST['onderwerp']); // Verwijder \n $_POST['onderwerp'] = str_replace('\r', '', $_POST['onderwerp']); // Verwijder \r $_POST['onderwerp'] = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_POST['onderwerp'])); // Slashes van quotes if (mail($mail_ontv, $_POST['onderwerp'], $inhoud_mail, $headers) && mail($_POST['mail'], $_POST['onderwerp'], $inhoud_mail, $headers)) { // zorg ervoor dat dezelfde persoon niet kan spammen $_SESSION['antiflood'] = time(); echo ' <p>Bedankt voor het invullen van het contactformulier.<br /> We zullen zo spoedig mogelijk contact met u opnemen.</p>'; } else { echo ' <p><b>Onze excuses.</b> Het contactformulier kon niet verzonden worden.</p>'; } } ?> </td> <td> <iframe width="375" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" align="right" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=vlezenbeek+postweg+126&aq=&sll=37.160317,-95.712891&sspn=34.778245,79.013672&ie=UTF8&hq=vlezenbeek+postweg+126&hnear=&radius=15000&ll=50.807956,4.232348&spn=0.071946,0.071946&output=embed"></iframe><br /></small> </td> </tr> </table> </div> <div id="rechterbalk"> </div> <div id="footer"> </div> </div> <iframe width="350" height="275" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" align="right" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=vlezenbeek+postweg+126&aq=&sll=37.160317,-95.712891&sspn=34.778245,79.013672&ie=UTF8&hq=vlezenbeek+postweg+126&hnear=&radius=15000&ll=50.807956,4.232348&spn=0.071946,0.071946&output=embed"></iframe><br /></small> </div> </body> </html>
  18. just this little sentence? Where do I put it? I've got this kind of structure: if(all checks are okay){ submit contactform and show thank you message} Just below the thank you message?
  19. hey, I'm working on a contact form. The form is being checked on correct values. If not completed correctly, the form shows again with a warning at the wrong or forgotten fields and the right fields remain fild in. After submitting with correct inputdata, there is a message shown in the same page saying "thank you, we'll contact you as fast as possible,...". But I would like to redirect the page to the homepage about 5 seconds after the message is being shown. This is the form header part: <form method="post" action="' .$_SERVER['REQUEST_URI'] . '" /> How can I make this form say "thank you" when the values are right (in the same page or another, that doesn't really matter) and then make it jump to the homepage again? thanks in advance
  20. hey every one, I'm working on forms lately but there is one thing I don't understand. I have a select menu in my html form. Now I want a second one underneath it whos values should vary depending on what the selection in the first menu is. For that I should use php but I don't know how. Can I somehow insert an if structure inside my html? This is an example of my first select menu: <select name="chooseCourse"> <option value="One">One</option> <option value="Two">Two</option> </select> The next should be a menu containing different dates, displaying in the dropdown the correct dates for the above selected course: <select name="chooseDate4CourseOne"> <option value="first">10/10/2010-5/12/2010</option> <option value="second">5/12/2010-20/02/2011</option> <option value="third">25/02/2011-25/04/2011</option> </select> Now I was thinking how to create this. I thought the best way would be to make inside php an html part using : <<<<_HTML_ in here a select date menu for the first course >>>> and make this for every date menu. Then simply use an if structure to do: if firstvalue is selected, show firstdatemenu. If the previous part would work it would leave me with one problem. The second menu will not be adjusted as long as the form is not submitted. Somehow when a selection is made, imediatelly the 2nd menu should be somehow adjusted/refreshed. How can I do this? What do you think of the first part using those different html parts inside php? Would it work? And if so, how do make the date menu adapt? a lot of thanks in advance!
  21. thanks a lot! I would've never found that one :s Solved!
  22. after testing every function by marking it as comment I noticed they don't have a negativ effect. The error occurs when "print<<< _HTML_" starts
  23. that doesn't change a thing. I also noticed in NP++ that the function show_form has no matching "}" after the htmlform part. It only matches if I put it after the first if-statement. But still my "?>" stays gray so there's still something wrong
  24. hey, I get this error on line 69 which is the end of my code, but I just can't find the missing or wrong curly bracket :s <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <p> <?php if(isset($_POST['_submit_check'])){ if($form_errors = validate_form()){ show_form($form_errors);} else{ process_form();}} else{ show_form();} function process_form(){ print "Hello, ".$_POST['user'];} if(array_key_exists('user', $_POST)){ process_form();} else{ show_form(); } function validate_form(){ $errors = array(); if(strlen($_POST['user']) < 1){ $errors[] = 'Your name must be at least 1 letter long.'; } return $errors;} if(array_key_exists('_submit_check', $_POST)){ if(validate_form()){ proces_form(); } else{ show_form();} } else{ show_form(); } function show_form($errors = ''){ if($errors){ print 'please correct these errors: <ul><li>'; print implode('</li><li>', $errors); print '</li></ul>'; } print<<<_HTML_ <form method = "POST" action="$_SERVER[php_SELF]"> Your name: <input type="text" name="user"> </br> <input type="submit" value="Verzenden"/> </br> <input type="hidden" name="_submit_check_" value="1"> </form> _HTML_; } ?> </p> </body> </html>
  25. because the menu has to change into new links of the elevant page.Like when clicking on taxonomie,the menu should change to the main specieslinks and a home link.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.