ingerNorway Posted September 10, 2013 Share Posted September 10, 2013 Hi i'm new in this forum, but it looks like I can get help here I'm trying to figure out what I've do wrong but can't figure out. The error i get is: Fatal error: Call to undefined function validerFornavn() in /jail/www/inghor/tema5/inkluderevalidering.php on line 5/* my php code is /* <?php include ("validering-navn.php"); $fornavn=$_POST ["fornavn"]; $etternavn=$_POST ["etternavn"]; $lovligFornavn=validerFornavn($fornavn); $lovligEetternavn=validerEtternavn($etternavn); if(!$lovligfornavn) { print("navn er ikke fylt ut riktig<br/>"); } if(!$lovligetternavn) { print("etternavn er ikke fylt ut riktig<br/>"); } if ($lovligfornavn && $lovligetternavn) { $filnavn="navn.txt"; $filopprasjon="a"; $linje=$fornavn." ".$etternavn."\n"; $fil=fopen($filnavn,$filopprasjon); fwrite($fil, $linje); fclose($fil); print("$fornavn $etternavn er nå skrevet til fil<br/>"); } ?>/* This is the function file I includet "validering-navn.php" /* function validerFornavn($fornavn) { $lovligfornavn=1; if (!$fornavn) { $lovligfornavn=0; } if ($lovligfornavn) { return true; } else { return false } } Function validerEtternavn($etternavn) { $lovligetternavn=1; if (!$etternavn) { $lovligetternavn=0; } if ($lovligetternavn) { return true; } else { return false; } } ?>/** and this is my html */<!DOCTYPE html> <html> <head> <title> navn tekstfil </title> </head> <body> <h3> navn tekstfil </h3> <form method="post" action="inkluderevalidering.php" id="inkludervalidering" name="inkludervalidering"> fornavn <input type="text"id="fornavn" name="fornavn"/><Br/> etternavn <input type="text" id="etternavn" name="etternavn"/><br/> <Input type="submit" value="fortsett"id="fortsett" name="fortsett"> <input type="reset" value="nullstill"id="nullstill"name="nullstill"><br/> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/282037-basic-php-call-to-undefined-function/ Share on other sites More sharing options...
cyberRobot Posted September 10, 2013 Share Posted September 10, 2013 Is that the exact code from validering-navn.php? If so, you need to include the open PHP tag. <?php //<-- ADD THIS function validerFornavn($fornavn) { //... ?> Link to comment https://forums.phpfreaks.com/topic/282037-basic-php-call-to-undefined-function/#findComment-1448966 Share on other sites More sharing options...
ingerNorway Posted September 10, 2013 Author Share Posted September 10, 2013 Thanks.. It's often the little things.. It was the php tag and write acsess to the folder with the .txt file Link to comment https://forums.phpfreaks.com/topic/282037-basic-php-call-to-undefined-function/#findComment-1448969 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.