Jump to content

Basic PHP, Call to undefined function


ingerNorway

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.