real_illusions Posted February 20, 2006 Share Posted February 20, 2006 i'm setting up this page with ajax, in a way that links target a certain div and load from an external file. also means the url stays the same.basically, this means replacing the href links with this - <a href="java script:ajaxpage('homeinc.php', 'mainpagelayer');">home page</a>the problem arises with form/email sending.the action attribute is usually action="formprocess.php"but, this creates a new page, which i dont want.but, making the action like this - action="java script:ajaxpage('formprocess.php', 'mainpagelayer');"the information put in the fields doesn't appear in the email, but it still sends the email.but it still writes in the mainpagelayer div "thanks, your email is sent" or whatever you want writing in there, but <p>Thank you <?php echo $_POST["name"]; ?>.</p>no name appears.any ideas? Link to comment Share on other sites More sharing options...
DarkElf Posted February 20, 2006 Share Posted February 20, 2006 This quite an interesting problem. I've never tried doing that kind of javascript thing so I might be wrong about this, but I think I might know what is going on.When the user submits a form the contents are submitted to the post array for the page which is loaded by the action attribute, this array is stored by your browser and the server takes information from it, similar to a cookie really. But I think that because of the way you are doing it the post array in your browser doesn't get refreshed, only the contents of the div do. Normally this is a good thing (atleast for what you are trying to do), the rest of the page including the url stays the same - a neat trick which saves unneccasary downloads of repeated information, speeding up your site for users and reducing traffic on your server.Unfortuntately it causes you problems when using form inputs. You submit the form and the inputs are sent to the array for formproccess.php, but the page loaded in your browser is not formprocess.php, it is your index page so the post array in the browser is empty. Therefore the mail script executes and sends an email when it is called, but when it checks the browser for the post array it finds nothing so sends an empty e-mail. Link to comment Share on other sites More sharing options...
DarkElf Posted February 20, 2006 Share Posted February 20, 2006 Oops, sorry, forgot to add a solution I suggest that you work around this by exiting from your ajax script for a brief time. Use form action 'formproccess.php' but then include a meta refresh on the formprocess page to bounce the user back to the ajax page loading the confirmation message in the relevant div. It means you need to use 3 pages to handle the whole email form instead of 2, but the user will probably not even see the one in the middle it refreshes so fast anyway. Link to comment Share on other sites More sharing options...
real_illusions Posted February 20, 2006 Author Share Posted February 20, 2006 thanks alot :)although i added the refresh on the thank you page which is basically a blank page with the thanks on, then redirects the user back to the homepage.looks like everything workshttp://www.midlandkarting.co.ukto see it in action Link to comment Share on other sites More sharing options...
DarkElf Posted February 20, 2006 Share Posted February 20, 2006 http://www.midlandkarting.co.ukto see it in action Your website is broken the email form doesn't seem to exist at the moment, you might want to fix that! Link to comment Share on other sites More sharing options...
real_illusions Posted February 20, 2006 Author Share Posted February 20, 2006 Your website is broken the email form doesn't seem to exist at the moment, you might want to fix that!<{POST_SNAPBACK}> no its not..it is there Link to comment Share on other sites More sharing options...
hacknsack Posted February 21, 2006 Share Posted February 21, 2006 DarkElf is correct there is some sort of problem this is the error when I click on the "click here". Warning: main(emailform2.php): failed to open stream: No such file or directory in /home/mkarting/public_html/emailinc.php on line 17Warning: main(): Failed opening 'emailform2.php' for inclusion (include_path='.:/usr/share/pear') in /home/mkarting/public_html/emailinc.php on line 17 The above happened in IE6. Link to comment Share on other sites More sharing options...
real_illusions Posted February 21, 2006 Author Share Posted February 21, 2006 hmmm..strange.it works here in IE6 Link to comment Share on other sites More sharing options...
hacknsack Posted February 21, 2006 Share Posted February 21, 2006 Here's what's happening:If at the home page user hits Info/Email the form appears.If the user hits Contact, clicks here (enquiries), the error appears. Warning: main(emailform2.php): failed to open stream: No such file or directory in /home/mkarting/public_html/emailinc.php on line 17Warning: main(): Failed opening 'emailform2.php' for inclusion (include_path='.:/usr/share/pear') in /home/mkarting/public_html/emailinc.php on line 17 Also errors on info pack.-hs Link to comment Share on other sites More sharing options...
real_illusions Posted February 21, 2006 Author Share Posted February 21, 2006 very strangeit worked for me in both firefox and explorer here at home, and in explorer at work, and it worked for someone else too.i've taken the ajax stuff off now and reverted back to how it was originally. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now