Ninjakreborn Posted May 18, 2006 Share Posted May 18, 2006 Sorry for yet another post, but I ran into a problem, that seems to be related to php. I don't understand this. Ok I have showed my form before, Here is my code[code]<?phpif ($_POST['firstname'] == ""){print("Please go back and fill int he First Name field correctly<br />");}if ($_POST['emailaddress'] == ""){print("Please go back and fill in the Email Address field correctly<br />");}if ($_POST['verifyemail'] == ""){print("Please go back and fill in the Verify Email field correctly<br />");}if ($_POST['description'] == ""){print("Please go back and fill in the Description field correctly<br />");}if ($_POST['emailaddress'] !== $_POST['verifyemail']){print("Unfortunately the email addresses did not match, please recheck what you put");}else {$firstname = $_POST['firstname'];$emailaddress = $_POST['emailaddress'];$verifyemail = $_POST['verifyemail'];$description = $_POST['description'];$to = "businessman332211@hotmail.com";$subject = "ideas and submissions";$message = "First Name: $firstnameEmail Address: $emailaddressVerify Email: $verifyemailDescription: $description";if(mail($to, $subject, $message)) {print("Thank you for submitting your email has been successfully sent");print("<br />Return to the homepage at <a href='http://www.freelancebusinessman.com'>Freelance Businessman</a>");}else{print("I am sorry but there was some sort of error and the email could not be sent");print("<br />I am not totally sure of the cause of this error.");print("<br />Please return to <a href='http://www.freelancebusinessman.com'>Freelance Businessman</a>");print("<br />If you try again and recieve this error message a second time, then please email me at the original email address and notify me of this error, so it can be checked into. Thank you for visiting Freelance Businessman.");}}?>[/code]This is the problem. At first it wasn't sending the email, when I just had the email command in there, I got it working, then I incorporated the validation, and got it working, but it would validate it and send it anyway, then I formed the code as shown above, it worked, except for the last if statement, for instance, before it worked, but I added that last section [code]}if ($_POST['emailaddress'] !== $_POST['verifyemail']){print("Unfortunately the email addresses did not match, please recheck what you put");}else {[/code]when I added this last line of code it stopped working correctly and now again it started doing that, it started automatically sending the email and validating it at the same time, am I limited to how many if statements I can put before the else statement, or did I do it wrong somehow. Quote Link to comment https://forums.phpfreaks.com/topic/9936-ran-into-major-problem/ Share on other sites More sharing options...
alpine Posted May 18, 2006 Share Posted May 18, 2006 You are doing a lot of if's with one elsetry something like this[code]if (empty($_POST['firstname'])){print("Please go back and fill int he First Name field correctly<br />");}elseif (empty($_POST['emailaddress'])){print("Please go back and fill in the Email Address field correctly");}elseif (empty($_POST['verifyemail'])){print("Please go back and fill in the Verify Email field correctly<br />");}elseif (empty($_POST['description'])){print("Please go back and fill in the Description field correctly<br />");}elseif ($_POST['emailaddress'] !== $_POST['verifyemail']){print("Unfortunately the email addresses did not match, please recheck what you put");}else{ // send}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/9936-ran-into-major-problem/#findComment-36924 Share on other sites More sharing options...
Ninjakreborn Posted May 18, 2006 Author Share Posted May 18, 2006 Thanks, that finally got everything working on that, and gave me something to look at in the future when I am doing things with these as well, thanks again for the help. Quote Link to comment https://forums.phpfreaks.com/topic/9936-ran-into-major-problem/#findComment-36936 Share on other sites More sharing options...
otuatail Posted May 18, 2006 Share Posted May 18, 2006 I have used session variables to store all the fields entered with blank sessions variables obviouslywhere nothing is entered. re-directing back to the form populating the fields already entered. and turningthe text red or bold against the form entries that are blank and require filling in. ALSO a message at the topexplaing why.I have had problems where the email has not been sent and it has been around the extra variable $headder$success = mail($to,$sss, $mmm, $headers); where $header was$headers = "From: $name <$from>\r\n";also my Web hosting guy changed something on the server and I had to add a line above thisini_set("sendmail_from", "root@des-otoole.co.uk");But I have also been told not to rely on the return value of the mail() function.Hope this helps.P.S. Try doing this in Microsoft ASP. count the grey hairs.Desmond. Quote Link to comment https://forums.phpfreaks.com/topic/9936-ran-into-major-problem/#findComment-36978 Share on other sites More sharing options...
Ninjakreborn Posted May 18, 2006 Author Share Posted May 18, 2006 I'll take what you gave me and play around with it, see what I can come up with thanks. I don't know much asp, I am planning on only learning it enough to get by when a client needs something done. Php is my pride and joy, it's funner than any other server side languages I have played with. I have moved on now to trying to javascript validation, I am getting better at programming overall lately. Quote Link to comment https://forums.phpfreaks.com/topic/9936-ran-into-major-problem/#findComment-36980 Share on other sites More sharing options...
otuatail Posted May 18, 2006 Share Posted May 18, 2006 Good LuclI am the otherway around ASP for years, but feeling very battered and brused with PHP although I have a C and C++ background. Same as PHP Semi's on ends of lines. Most C++ functions seem the same.Good luck again. Des. Quote Link to comment https://forums.phpfreaks.com/topic/9936-ran-into-major-problem/#findComment-36982 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.