TheLovableCodeyMan Posted April 22, 2021 Share Posted April 22, 2021 Greetings Fellow PHPFreaks! LovableCodeMan here - newbie to this forum an pretty new to this PHP thing that all these youngsters are raving about - who knew?! Anyway, so I have an HTML form set up with a PHP document attached in order to send the data from the form to an email -a pretty basic setup by todays standards. In the PHP document, you can see that there is a section for the user (sender@xyz.com) to submit the information in the form to us & is sent to our email address "receiver@xyz.com". The bottom segment is to send a confirmation email back to the sender - to "sender@xyz.com" - as a thank you and a "We will get back to you ASAP" etc etc etc. The confirmation email sent to the sender@xyz.com works flawlessly when pressing the "Send Your Message" button, but then I just see "https://www.xyz.com/scripts/mail.php" in the address bar and no email is received by receiver@xyz.com - aka "Us". This is the PHP document - confidential information redacted & the "sender@xyz.com" & "receiver@xyz.com" replace the real email addresses. <!doctype html> <?php $title = $_POST['title']; $first = $_POST['first']; $surname = $_POST['surname']; $email = $_POST['email']; <!------- sender@xyz.com---> $internationalCode = $_POST['internationalCode']; $number = $_POST['number']; $userMessage = $_POST['userMessage']; $company = $_POST['company']; $Industrytype = $_POST['Industrytype']; $inc_status = $_POST['inc_status']; $state = ['state']; $email_from = "$first $surname <smtp server login>"; $Password = 'smtp server password'; $email_subject = "Website Enquiry from $first $surname"; $messageTo = "receiver@xyz.com"; $email_body = "User title: $title. \n". "The department this message is for is: $department.\n". "User First Name: $first.\n". "User Surname Name: $surname. \n". "User email: $email.\n". "International Dialing Code: $internationalCode. \n". "User Contact Number: $number.\n". "State of Incorporation: $state.\n". "File: $attachment.\n". "Company Name: $company, $inc_status.\n". "Industry type: $Industrytype.\n". "User Message is: $userMessage.\n"; $headers = "From: $email_from" . "\r\n" . "Reply to: $first $surname". "\r\n"; mail($messageTo, $email_subject, $email_body, $headers, "-fweb_support@xyz.com"); header('Location: https://www.xyz.com/thank_you.html'); <!--------Confirmation email send to sender@xyz.com below----------------> $respond_subject = "Thank you for your message"; /* Prepare autoresponder message */ $respond_message = " Hi $first, Thank you for messaging to us. We will aim to reply to you within 24 hours. In the meantime, why not follow our other stories via, as well as following, our Facebook page. Simply go to https://www.facebook.com/xyz/ Yours sincerely, The Support Team receiver@xyz.com. "; $headers = 'From: <Sender> <no-reply@xyz.com>' . "\r\n" . 'Reply-To: $email' . "\r\n" .<!------- sender@xyz.com---> 'X-Mailer: PHP/' . phpversion(); /* Send the message using mail() function */ mail($email, $respond_subject, $respond_message, $headers, "-fno-reply@xyz.com"); //} ?> This is the HTML document: <!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> </head> <body> <form role="form-inline" method="POST" action="../scripts/mail.php"> <div class="form-group"> <div class="row"> <div class="col-lg-2 col-md-4 col-sm-4 col-xs-4 select "> <select class="" id="standard-select" name="title"> <option selected disabled>Title *</option> <option>Dr.</option> <option>Mr.</option> <option>Mrs.</option> <option>Ms.</option> <option>Prof.</option> <option>Rev.</option> <option>Pastor.</option> <option>Miss.</option> </select> </div> <div class="col-lg-4 col-md-4 col-sm-8 col-xs-8"> <input name="first" type="text" placeholder="First Name *" required/> </div> <div class="col-lg-6 col-md-4"> <input name="surname" type="text" placeholder="Surname *" required/> </div> </div> <div class="row"> <div class="col-lg-6 col-md-4 col-sm-6 col-xs-12"> <input name="email" type="email" placeholder="Email *" required/> </div> <label for="standard-select"></label> <div class="col-lg-2 col-md-4 col-sm-6 col-xs-5 select"> <select class="" name="internationalCode" id=""> <option data-countryCode="GB" value="44" Selected>UK (+44)</option> <option data-countryCode="US" value="1" >USA (+1)</option> <optgroup label="Other countries"> <option data-countryCode="DZ" value="213">Algeria (+213)</option> <option data-countryCode="AD" value="376">Andorra (+376)</option> <option data-countryCode="AO" value="244">Angola (+244)</option> <option data-countryCode="AI" value="1264">Anguilla (+1264)</option> <option data-countryCode="AG" value="1268">Antigua & Barbuda (+1268)</option> <option data-countryCode="AR" value="54">Argentina (+54)</option> <option data-countryCode="AM" value="374">Armenia (+374)</option> </optgroup> </select> </div> <div class="col-lg-4 col-md-4 col-sm-12 col-xs-7"> <input type="tel" name="number" placeholder="Telephone Number *" required/> </div> </div> <div class="row"> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 select"> <select name="inc_status" required> <option selected disabled>Incorporation status *</option> <option>Limited by Guarantee</option> <option>Limited by Shares</option> <option>CIC</option> <option>CIO</option> <option>Unincorporated</option> <option>LLP</option> <option>LLC</option> <option>Other</option> </select> </div> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 select"> <select name="state" disabled> <option selected disabled>State of incorporation *</option> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <option value="CA">California</option> <option value="CO">Colorado</option> <option value="CT">Connecticut</option> <option value="DE">Delaware</option> <option value="DC">District Of Columbia</option> <option value="FL">Florida</option> </select> </div> </div> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <input name="company" type="text" placeholder="Company *" required/> </div> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 select"> <select class="" name="Industrytype" id="select" value=""> <option selected disabled value="">Industry *</option> <option value="Appraisal/Disposition">Appraisal/Disposition</option> <option value="Business Services">Business Services</option> <option value="Consulting">Consulting</option> <option value="Business Broker">Business Broker</option> <option value="Distribution">Distribution</option> <option value="Education">Education</option> <option value="Financial Services (Non-Lender)">Financial Services (Non-Lender)</option> <option value="Government">Government</option> <option value="Healthcare">Healthcare</option> <option value="Insurance">Insurance</option> <option value="Investment Banking">Investment Banking</option> <option value="Law">Law</option> <option value="Lender">Lender</option> <option value="Logistics">Logistics</option> <option value="Manufacturing">Manufacturing</option> <option value="Media/Print/Broadcast/Internet">Media/Print/Broadcast/Internet</option> <option value="Other">Other</option> <option value="Private Equity/Venture Capital">Private Equity/Venture Capital</option> <option value="Real Estate Services">Real Estate Services</option> <option value="Receivables">Receivables</option> <option value="Retail">Retail</option> <option value="Technology">Technology</option> <option value="Turnaround/Restructuring">Turnaround/Restructuring</option> <option value="Utility">Utility</option> <option value="Wholesale">Wholesale</option> </select> </div> </div> <div class="row"> <div class="col-lg-12"> <textarea name="userMessage" placeholder="Please type your message here. Do not include any personal information such as your NIN or any banking information."></textarea> </div> </div> <div class="row"> <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12"> <div class="" style="background-color: #E0DDDD; padding: 20px;"> <p style="font-size: 12px; color: #0d0155">Information is held under the provision of the General Data Protection Regulation (GDPR). We will not pass your details on to any other organisation. We will process your information in accordance with our privacy policy. By send this message, you agree to xxxxxxx's <a style="color: #0D0155; text-decoration: underline;" href="/privacy/online_privacy_notice.html" target="_new" class="inline_link__new_window">Online Privacy Policy</a> </p> </div> </div> <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12"> <input type="submit" id="submit" name="submit" value="Send your message"/> </div> </div> </div> </form> </body> </html> Anyone know where I'm going wrong, it "half works" so I'm Half Way There - & yes, I am Livin' on a Prayer! Thanks in advance! The LovableCodeman Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/ Share on other sites More sharing options...
gw1500se Posted April 22, 2021 Share Posted April 22, 2021 First I highly recommend you use PHPMailer. It is much easier, more robust and gives you more control. You are not checking the return code from 'mail'. It will return true on success or false on failure. Your code does not know if it is successful or not. In any case that is only half the problem. You also need to check your MTA. What are you using? Does your mail server require a sign-in to send mail. Have you looked at your mail log for any errors? Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586074 Share on other sites More sharing options...
phppup Posted April 22, 2021 Share Posted April 22, 2021 As previously mentioned, YES, place some functional validation to determine IF the system sent the email. Something like Quote echo "Your message was sent"; } else { echo "Something went wrong"; This will not only help you during development, but also benefit the user when operational. And, as often recommended, turn on ERROR REPORTING by placing this immediately after your opening PHP tag <? Quote ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); (if you haven't used this, just do something blatantly wrong and then run the page to see the result) ** Remove it BEFORE production ** Aside from your CODE, other variables can be in-play with email. Spam filters are notorious for creating issues. If you're sending and receiving identical messages repeatedly, the safety net may outsmart itself and cause you an issue. I've personally had emails take hours until being released by the server. Or tested soooo many times that a failure/spam designation stopped everything. My suggestion: if the code is good, send an email to an outside address and confirm it to another (with a subject line that does NOT contain "test" or "sample" etc). - EVERYTHING has to 'appear' to be "real/valid" communication. Once you've established that messages are being sent and received adequately, then you can gingerly tweak the settings (with a degree of confidence). Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586076 Share on other sites More sharing options...
TheLovableCodeyMan Posted April 22, 2021 Author Share Posted April 22, 2021 17 minutes ago, phppup said: As previously mentioned, YES, place some functional validation to determine IF the system sent the email. Something like This will not only help you during development, but also benefit the user when operational. And, as often recommended, turn on ERROR REPORTING by placing this immediately after your opening PHP tag <? (if you haven't used this, just do something blatantly wrong and then run the page to see the result) ** Remove it BEFORE production ** Aside from your CODE, other variables can be in-play with email. Spam filters are notorious for creating issues. If you're sending and receiving identical messages repeatedly, the safety net may outsmart itself and cause you an issue. I've personally had emails take hours until being released by the server. Or tested soooo many times that a failure/spam designation stopped everything. My suggestion: if the code is good, send an email to an outside address and confirm it to another (with a subject line that does NOT contain "test" or "sample" etc). - EVERYTHING has to 'appear' to be "real/valid" communication. Once you've established that messages are being sent and received adequately, then you can gingerly tweak the settings (with a degree of confidence). The code is fine, as an update, the confirmation email from the sender is received 22 minutes ago, phppup said: As previously mentioned, YES, place some functional validation to determine IF the system sent the email. Something like This will not only help you during development, but also benefit the user when operational. And, as often recommended, turn on ERROR REPORTING by placing this immediately after your opening PHP tag <? (if you haven't used this, just do something blatantly wrong and then run the page to see the result) ** Remove it BEFORE production ** Aside from your CODE, other variables can be in-play with email. Spam filters are notorious for creating issues. If you're sending and receiving identical messages repeatedly, the safety net may outsmart itself and cause you an issue. I've personally had emails take hours until being released by the server. Or tested soooo many times that a failure/spam designation stopped everything. My suggestion: if the code is good, send an email to an outside address and confirm it to another (with a subject line that does NOT contain "test" or "sample" etc). - EVERYTHING has to 'appear' to be "real/valid" communication. Once you've established that messages are being sent and received adequately, then you can gingerly tweak the settings (with a degree of confidence). Hello there, I have inserted diagnostic code immediate after the opening PHP tag <? (Which is great to know, by the way, I never knew this) & I get the following: Notice: Undefined variable: department in /homepages/4/d860010751/htdocs/scripts/mail.php on line 27 Notice: Array to string conversion in /homepages/4/d860010751/htdocs/scripts/mail.php on line 33 Notice: Undefined variable: attachment in /homepages/4/d860010751/htdocs/scripts/mail.php on line 34 Warning: Cannot modify header information - headers already sent by (output started at /homepages/4/d860010751/htdocs/scripts/mail.php:27) in /homepages/4/d860010751/htdocs/scripts/mail.php on line 43 Also, I'm still getting the confirmation email to (sender@xyz.com) - which is good, but still not receiving the information submitted in the form. Also checking the SMTP suppliers records, yes, the sender@xyz.com has been treated as "Delivered" which is true, and the receiver@xyz.com as "Processed" All the best, The LovableCodeMan! Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586078 Share on other sites More sharing options...
phppup Posted April 22, 2021 Share Posted April 22, 2021 If you put the first few words of a notification into a search engine, you can generally begin to find an understanding (and hopefully a solution). The last item of the message that provides "line #" is referencing the line in your CODE where the error occurred. (Taking into account that sometimes the error existed but didn't cause a problem until this point, the line number is accurate.) Depending on your code editor, the line numbers are available, although counting to line 21 isn't nearly as difficult as finding line 642. LOL. (an empty line is still a counted line) Make sure to eliminate the error initiation code BEFORE going live. It gives too much information to a user if displayed at an inopportune time. I'll take another look at your code, but beyond this point, there are other people here that would be more capable than myself. Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586079 Share on other sites More sharing options...
TheLovableCodeyMan Posted April 22, 2021 Author Share Posted April 22, 2021 Just now, phppup said: If you put the first few words of a notification into a search engine, you can generally begin to find an understanding (and hopefully a solution). The last item of the message that provides "line #" is referencing the line in your CODE where the error occurred. (Taking into account that sometimes the error existed but didn't cause a problem until this point, the line number is accurate.) Depending on your code editor, the line numbers are available, although counting to line 21 isn't nearly as difficult as finding line 642. LOL. (an empty line is still a counted line) Make sure to eliminate the error initiation code BEFORE going live. It gives too much information to a user if displayed at an inopportune time. I'll take another look at your code, but beyond this point, there are other people here that would be more capable than myself. Sure, I've tweaked some changed and have managed to reduce this down to: Notice: Array to string conversion in /homepages/4/d860010751/htdocs/scripts/mail.php on line 32 Warning: Cannot modify header information - headers already sent by (output started at /homepages/4/d860010751/htdocs/scripts/mail.php:32) in /homepages/4/d860010751/htdocs/scripts/mail.php on line 42 Which makes no sense because line 32 is ""State of Incorporation: $state.\n"." Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586080 Share on other sites More sharing options...
gw1500se Posted April 22, 2021 Share Posted April 22, 2021 The error may be occurring somewhere else but that is the point at which PHP could not go any further. Headers MUST be the first things sent. There can be nothing preceding headers including white space. Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586081 Share on other sites More sharing options...
TheLovableCodeyMan Posted April 22, 2021 Author Share Posted April 22, 2021 2 minutes ago, gw1500se said: The error may be occurring somewhere else but that is the point at which PHP could not go any further. Headers MUST be the first things sent. There can be nothing preceding headers including white space. Awesome, so placing Quote $headers = "From: $email_from" . "\r\n"; immediately after the: Quote <?php so therefore: Quote <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);$headers = "From: $email_from" . "\r\n"; Is that correct? Regards The LovableCodeMan Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586082 Share on other sites More sharing options...
TheLovableCodeyMan Posted April 22, 2021 Author Share Posted April 22, 2021 (edited) 23 minutes ago, gw1500se said: The error may be occurring somewhere else but that is the point at which PHP could not go any further. Headers MUST be the first things sent. There can be nothing preceding headers including white space. So a wee update for you's all (No idea why I launched into Scottish there - I'm from nowhere near Scotland!) 😄 I'm no longer receiving error messages - which is good - It goes straight to the "Thank you" page - which is good, and the Confirmation Email is being received with no issues. Looking at the SMTP activity, the receiver@xyz.om is not recorded anywhere, so it's not even attempting to send the form information. Edited April 22, 2021 by TheLovableCodeyMan Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586084 Share on other sites More sharing options...
phppup Posted April 22, 2021 Share Posted April 22, 2021 (edited) Then we did it? Hurray!! Glad we could help. (Don't forget to remove or comment hide the error reporting) Edited April 22, 2021 by phppup Forgot item Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586085 Share on other sites More sharing options...
TheLovableCodeyMan Posted April 22, 2021 Author Share Posted April 22, 2021 (edited) 7 minutes ago, phppup said: Then we did it? Hurray!! Glad we could help. (Don't forget to remove or comment hide the error reporting) Lol not quite, the confirmation email is being sent to sender@xyz.com - which is brilliant - but no form information is being sent to receiver@xyz.com. Looking at the SMTP activity records with SendGrid, the "receiver" email address is not mentioned anywhere, so the server is not even attempting to send the form data. There are no block or suppressions on SendGrid either - I checked as I have been caught out by that before 😄 The receiver@xyz.com is still the issue 😄 Edited April 22, 2021 by TheLovableCodeyMan Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586086 Share on other sites More sharing options...
gw1500se Posted April 22, 2021 Share Posted April 22, 2021 Again, you are not checking the return code from 'mail'. Also the reply to header does not look like a valid email address. Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586087 Share on other sites More sharing options...
phppup Posted April 22, 2021 Share Posted April 22, 2021 I would hardcode the troublesome header and see what happens. Maybe the code doesn't like something in $headers = "From: $email_from" . "\r\n"; PS: I did notice the command sending the user to the "Thank you" page. You could expand it and do something like Quote if(mail(.... blah, blah...) { header('Location... blah blah } ELSE { echo "Message failed. Try again"; } Gotta go get a COVID shot. Good luck. Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586088 Share on other sites More sharing options...
TheLovableCodeyMan Posted April 22, 2021 Author Share Posted April 22, 2021 10 minutes ago, phppup said: I would hardcode the troublesome header and see what happens. Maybe the code doesn't like something in $headers = "From: $email_from" . "\r\n"; PS: I did notice the command sending the user to the "Thank you" page. You could expand it and do something like Gotta go get a COVID shot. Good luck. 14 minutes ago, gw1500se said: Again, you are not checking the return code from 'mail'. Also the reply to header does not look like a valid email address. Ah, first or second? If your first, people have varying side effects but I was fine, had what felt like a bruise for a few days but other than that I was perfecto. So I did the following: Quote if(mail($messageTo, $email_subject, $email_body, $headers, "-fnotifications@xxx.co.uk")){ header('Location: https://www.xxx.com/help/thank_you.html'); } else{ echo "Message failed. Try again"; } & had the following message Quote Notice: Array to string conversion in /homepages/4/d860010751/htdocs/scripts/mail.php on line 34 Message failed. Try again Line 34 is: Quote "State of Incorporation: $state. \n"; I don't see why this, of all things, wound hinder the process. But it looks like this is the culprit. Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586089 Share on other sites More sharing options...
TheLovableCodeyMan Posted April 22, 2021 Author Share Posted April 22, 2021 UPDATE - Revised Code, same problem <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $title = $_POST['title']; $first = $_POST['first']; $surname = $_POST['surname']; $email = $_POST['email']; <!--sender@xyz.com--> $internationalCode = $_POST['internationalCode']; $number = $_POST['number']; $userMessage = $_POST['userMessage']; $company = $_POST['company']; $Industrytype = $_POST['Industrytype']; $inc_status = $_POST['inc_status']; $state = $_POST['state']; $email_from = "$first $surname <apikey>"; $Password = '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'; $email_subject = "Website Enquiry from $first $surname"; $messageTo = "sender@xyz.com"; $email_body = "User title: $title. \n". "User First Name: $first. \n". "User Surname Name: $surname. \n". "User email: $email. \n". "International Dialing Code: $internationalCode. \n". "User Contact Number: $number. \n". "Company Name: $company. \n". "Incorporation Status: $inc_status. \n". "Industry type: $Industrytype. \n". "User Message is: $userMessage. \n". "State of Incorporation: $state. \n"; $headers = "From: $email_from"; mail($messageTo, $email_subject, $email_body, $headers, "-fweb-support@xyz.co.uk"); header('Location: https://www.xyz.com/help/thank_you.html'); $respond_subject = "Thank you for your message"; /* Prepare autoresponder message */ $respond_message = " Hi $first, Thank you for messaging to us. We will aim to reply to you within 24 hours. In the meantime, why not follow our other stories via, as well as following, our Facebook page. Simply go to https://www.facebook.com/xyz/ or Message us on Facebook at http://m.me/xyz To see how your data is processed, please visit our Data Protection Policy here: https://www.xyz.com/privacy/privacy_central.html Yours sincerely, xxx"; $headers = 'From: xyz <notifications@xyz.co.uk>' . "\r\n" . 'Reply-To: $email' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); /* Send the message using mail() function */ mail($email, $respond_subject, $respond_message, $headers, "-fno-reply@xyz.co.uk"); //} ?> Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586091 Share on other sites More sharing options...
phppup Posted April 22, 2021 Share Posted April 22, 2021 In your HTML, the drop-down for states which provides the value for $state is DISABLED. Why????? Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586092 Share on other sites More sharing options...
gw1500se Posted April 22, 2021 Share Posted April 22, 2021 Comment out everything in the body except 1 line and see where the error goes. Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586093 Share on other sites More sharing options...
TheLovableCodeyMan Posted April 22, 2021 Author Share Posted April 22, 2021 Just now, phppup said: In your HTML, the drop-down for states which provides the value for $state is DISABLED. Why????? The website is for the UK market, so its irrelevant for over here, but it's going to be integrated into a US branch soon. so was easier to just disable this as opposed to coding in later on. Could this be a problem for this situation? Because I can feel my blood pressure starting to rise now, every time I run the suggested diagnostic testing, it throws up more errors, which I rectify, only to throw up even more errors. Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586096 Share on other sites More sharing options...
TheLovableCodeyMan Posted April 22, 2021 Author Share Posted April 22, 2021 3 minutes ago, gw1500se said: Comment out everything in the body except 1 line and see where the error goes. It's just a blank page. Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586097 Share on other sites More sharing options...
gw1500se Posted April 22, 2021 Share Posted April 22, 2021 Do you have errors turn on error_reporting(E_ALL); ? Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586098 Share on other sites More sharing options...
TheLovableCodeyMan Posted April 22, 2021 Author Share Posted April 22, 2021 3 minutes ago, TheLovableCodeyMan said: It's just a blank page. Sorry, just reread your post. This is what happens when you code and servers decide they're going to take a day off and I'm famished, the issues still persists, I'm getting the confirmation email but not getting the form information, and yes, I have turned on Quote ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); at the top of the page right after the first opening tag. Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586099 Share on other sites More sharing options...
phppup Posted April 22, 2021 Share Posted April 22, 2021 Take a break and get back to basics. Did you try @gw1500se suggestion? Add $state= "Test state"; one line above the culprit code line if the email is successfully processed with that text value, then you can resolve the issue with a comparison condition afterward. Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586100 Share on other sites More sharing options...
TheLovableCodeyMan Posted April 22, 2021 Author Share Posted April 22, 2021 Just now, phppup said: Take a break and get back to basics. Did you try @gw1500se suggestion? Add $state= "Test state"; one line above the culprit code line if the email is successfully processed with that text value, then you can resolve the issue with a comparison condition afterward. I did, it's going to the Thank You page, but when I do: Quote if(mail($messageTo, $email_subject, $email_body, $headers, "-fnotifications@xxx.co.uk")){ header('Location: https://www.xxx.com/help/thank_you.html'); } else{ echo "Message failed. Try again"; } I get the "echo" message but no diagnostic information - so still no idea why the code/server is deciding to not do as it's told. I'm going to come back to this tomorrow but I'm trying to keep my cool with this but it's just not working. Everything I try just does not want to know and even the diagnostics is giving me no reason for this, & right now I'm really beginning to lose my patience with this, I'm getting no error messages, warnings etc but I am getting just the: "Message failed. Try again"; which helps about as much as a chocolate fireguard. Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586101 Share on other sites More sharing options...
gw1500se Posted April 22, 2021 Share Posted April 22, 2021 (edited) As I originally said, you should use PHPMailer and it won't be as difficult to debug. You could have easily had it re-coded by now. Edited April 22, 2021 by gw1500se Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586103 Share on other sites More sharing options...
phppup Posted April 22, 2021 Share Posted April 22, 2021 You need to understand what your code is saying. The first version says: attempt this, attemp that, try to send mail, try going to the Thank You page. There are no indications or notifications of which success and which fail. The alternate version directs the process to EITHER go to the Thank You on success, or indicate failure. It's safe to safe the email is FAILING in all attempts. You just don't restrict it from going to the Thank You page on the first version. I would hardcode and see where that takes me. Also don't forget my initial statements about spam filters. I'm not familiar with PHPmailer, but it could be beneficial. Quote Link to comment https://forums.phpfreaks.com/topic/312535-html-form-only-shows-php-file-directory-in-the-address-bar-no-email-sent/#findComment-1586104 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.