programguru Posted June 28, 2008 Share Posted June 28, 2008 Hello, I am working on a script which has been kicking my butt long hours into the night, and I just wanted to see if any one had any input on what I am doing wrong. First off, my script is a "simple" mail script, and all I am trying to do is: 1) Test when the Submit button is clicked (but this seems to happen when the pages loads every time!!!_. 2) Next, test the entered email address for validity with a homemade function. 3) Send the email if the submit is true (pushed) and the email tests to TRUE. Note: isset() did not work for this (unless I was using it wrongly). The issues I am having is: 1) Page loads with email message "Sent..." or "Bad Email..." even if the Submit is not clicked. Meaning I either get one or the other with all of my experimenting, but all I want is the correct message to load after the Submit is clicked. Here are the applicable snippets of my code: The main validation function: function checkEmail($email) { if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) { return FALSE; } list($Username, $Domain) = split("@",$email); if(@getmxrr($Domain, $MXHost)) { return TRUE; } else { if(@fsockopen($Domain, 25, $errno, $errstr, 30)) { return TRUE; } else { return FALSE; } } } The Code for the actual script (one of many variations): if ($_GET['true'] AND checkEmail($email) == FALSE) { echo "<div align=\"center\" class=\"thankyou\">"; echo "Please enter a valid email address!"; echo "</div>"; } else { [b]... mail() code is here ...[/b] echo "<div align=\"center\" class=\"thankyou\">"; echo "Thank you! Your request has been submitted."; echo "</div>"; } Note: 1) My <form is tagged with "true" like: <form action="<?php echo $_SERVER['PHP_SELF']; ?>?submit=true" method="get"> - this is to test the "true". I've been up all night attempting variations of the if statement and testing the value of true, but nothing seems to work. I figure I just need an external eye to spot my stupid problem! Any ideas? Quote Link to comment Share on other sites More sharing options...
programguru Posted June 28, 2008 Author Share Posted June 28, 2008 Although I mentioned above, I just want to clarify the problem I cannot get around: My messages: "Please enter a valid email address!" and "Thank you! Your request has been submitted." load when the page loads. From all of my testing, this is the main issue I cannot get around (testing if elsif variations etc..) I must be doing something really dumb to not be able to solve this, but I just can't see straight any longer.... Quote Link to comment Share on other sites More sharing options...
programguru Posted June 28, 2008 Author Share Posted June 28, 2008 to clarify the messages are loading separately not together.. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 28, 2008 Share Posted June 28, 2008 From the description of the symptoms, the logic tests in your code are either non-existent or incorrect. There is no way anyone in a Forum will be able to specifically help you with what your code is doing unless you post all of it. If by "Global Vars On" you mean register_globals, DON'T write any code that is dependent on register_globals being on. They were turned off in 2002 and no new code should have been written after that point in time that used them. They have been completely removed in upcoming php6. Quote Link to comment Share on other sites More sharing options...
programguru Posted June 28, 2008 Author Share Posted June 28, 2008 PFMaBiSmAd, Yes you are correct: register_globals on ... I don't even know what I'm doing any longer I am so tired. I'm developing on an older server, and it's not mission critical. I assure you all of the code is not needed to resolve this. Quote Link to comment Share on other sites More sharing options...
programguru Posted June 28, 2008 Author Share Posted June 28, 2008 And I agree it is a logic issue. Quote Link to comment Share on other sites More sharing options...
programguru Posted June 28, 2008 Author Share Posted June 28, 2008 Any ideas? I know it is difficult isn't it :-( Quote Link to comment Share on other sites More sharing options...
programguru Posted June 28, 2008 Author Share Posted June 28, 2008 Well, I figured it out. For those who were trying to resolve this. These were the issues: 1) Lack of sleep 2) Weak coffee 3) Incorrect if nesting Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.