PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
mcoelho123
Forum Commoner
Posts: 37 Joined: Tue Jun 06, 2006 6:27 am
Post
by mcoelho123 » Wed Jun 07, 2006 4:49 am
I have this code, but is returning the following error:
Warning: Missing argument 1 for checkemail() in D:\Domains\caselcoop.pt\wwwroot\tests\include\mail.php on line 2
Code: Select all
function checkEmail($from) {
if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $from)){
list($username,$domain)=split('@',$from);
if(!checkdnsrr($domain,'MX')) {
return false;
}
return true;
}
return false;
}
if (checkEmail() == false){
header("Location: " . "../sendmail.php?msg=notsent&send=" . $send);
}
the $from is working well if i make echo $from;
Last edited by
mcoelho123 on Wed Jun 07, 2006 5:02 am, edited 1 time in total.
mcoelho123
Forum Commoner
Posts: 37 Joined: Tue Jun 06, 2006 6:27 am
Post
by mcoelho123 » Wed Jun 07, 2006 4:55 am
the message is
Warning: Missing argument 1 for checkemail() in D:\Domains\caselcoop.pt\wwwroot\tests\include\mail.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at D:\Domains\caselcoop.pt\wwwroot\tests\include\mail.php:2) in D:\Domains\caselcoop.pt\wwwroot\tests\include\mail.php on line 14
Why is not making the location:?
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Wed Jun 07, 2006 5:35 am
You have setup the checkEmail() function to have one parameter passed to it, you need to do this when you call the function, so keeping the function declaration as it is, change:
to
Mac
aerodromoi
Forum Contributor
Posts: 230 Joined: Sun May 07, 2006 5:21 am
Post
by aerodromoi » Wed Jun 07, 2006 5:37 am
mcoelho123 wrote: I have this code, but is returning the following error:
Warning: Missing argument 1 for checkemail() in D:\Domains\caselcoop.pt\wwwroot\tests\include\mail.php on line 2
Code: Select all
function checkEmail($from) {
if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $from)){
list($username,$domain)=split('@',$from);
if(!checkdnsrr($domain,'MX')) {
return false;
}
return true;
}
return false;
}
if (checkEmail() == false){
header("Location: " . "../sendmail.php?msg=notsent&send=" . $send);
}
the $from is working well if i make echo $from;
Looks like the function does not get fed properly
You'll have to call the function like this:
You'll have to check as well whether you echo something before calling the function (header problem).
btw 1: Your function will always return false - you'll have to include an else statement to make it work.
btw 2: A short version of your conditional statement:
aerodromoi
mcoelho123
Forum Commoner
Posts: 37 Joined: Tue Jun 06, 2006 6:27 am
Post
by mcoelho123 » Wed Jun 07, 2006 5:41 am
OK, now it always redirect to the page its TRUE even i enter a valid email, whats wrong??
mcoelho123
Forum Commoner
Posts: 37 Joined: Tue Jun 06, 2006 6:27 am
Post
by mcoelho123 » Wed Jun 07, 2006 5:42 am
sorry
i didnt change one of the funcion($from)
but now it gives me a error
Fatal error: Call to undefined function: checkdnsrr() in D:\Domains\caselcoop.pt\wwwroot\tests\include\mail.php on line 23
mcoelho123
Forum Commoner
Posts: 37 Joined: Tue Jun 06, 2006 6:27 am
Post
by mcoelho123 » Wed Jun 07, 2006 5:43 am
Code: Select all
function checkEmail($from) {
if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $from)){
list($username,$domain)=split('@',$from);
if(!checkdnsrr($domain,'MX')) {
return false;
}
return true;
}
return false;
}
if (checkEmail($from) == false){
header("Location: " . "../sendmail.php?msg=notsent&send=" . $send);
}
if (checkEmail($from) == true){
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Wed Jun 07, 2006 5:48 am
Are you running on a Linux server or a Windows one because the manual says:
php.net/checkdnsrr wrote: This function is not implemented on Windows platforms. Try the PEAR class Net_DNS.
You also still need an else statement in that function (as aerodromoi pointed out) or it will always return false - plus to stop it always returning true if it passes the preg_match(), try:
Code: Select all
function checkEmail($from)
{
if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $from)){
list($username,$domain)=split('@',$from);
if(!checkdnsrr($domain,'MX')) {
return false;
} else {
return true;
}
} else {
return false;
}
}
Mac
mcoelho123
Forum Commoner
Posts: 37 Joined: Tue Jun 06, 2006 6:27 am
Post
by mcoelho123 » Wed Jun 07, 2006 5:53 am
Windows i think
If it is how can i do?
mcoelho123
Forum Commoner
Posts: 37 Joined: Tue Jun 06, 2006 6:27 am
Post
by mcoelho123 » Wed Jun 07, 2006 5:54 am
yes it is
Windows NT HARPWRO-2 5.0 build 2195
How can i do, is there another way?
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Wed Jun 07, 2006 5:55 am
Check out the manual page for
checkdnsrr() it gives a link to an alternative package.
Mac
mcoelho123
Forum Commoner
Posts: 37 Joined: Tue Jun 06, 2006 6:27 am
Post
by mcoelho123 » Wed Jun 07, 2006 5:58 am
OK the webserver is not mine and i cant install anything (of course)
can u make a code that uses preg_match to check the mail?
mcoelho123
Forum Commoner
Posts: 37 Joined: Tue Jun 06, 2006 6:27 am
Post
by mcoelho123 » Wed Jun 07, 2006 6:00 am
or this is enough
Code: Select all
preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $from