Member
Member
joepinelli   2009-06-16, 03:18
#1

I'm using Zen Photo's built in contact form. Currently the form is placed in a div that's initial state is hidden. A visitor to the site can click a link that makes the div visible and they can enter their data. That all works just fine. The problem comes in when the form is submitted. The div hides itself again. If you click the link that makes the div visible the contact form is performing as it should, asking the user to confirm their submission.

I know the problem is caused by the page reloading and setting the div back to it's original state. I've tried using a postback function, but I'm afraid that may strictly be an ASP command and not suitable for the php form. Does anyone have any suggestions to tell the page "if you reloaded because of a form submit, make this div visible"?

Thanks

Administrator
Administrator
acrylian   2009-06-16, 08:50
#2

The easiest would be to customize the form template form.php. Place your div around the form there and add if/else check for the $_POST['sendmail'] (please look at the plugin code I do not remember correctly right now) to hide/unhide that div by either changing an attached css class for example.

Member
Member
sbillard   2009-06-16, 15:23
#3

So, you did not say which theme you were using. From the distribution, only the Effervescence+ them incorporates the contact form plugin. And it does not place the form in a hidden DIV.

So I would guess that you are using something else. Anyway, don't put the form in a hidden DIV if you want it to show.

Normally you would create a separate page for the contact form and link to it from wherever you wish on your other pages.

Member
Member
joepinelli   2009-06-16, 18:30
#4

sbillard, you are right I am using a custom theme. I have the contact form placed on my image.php. People click the email button and the contact form becomes visible. It works great with the exception that every time the page needs to refresh (ie for validation, confirmation, etc.) the div hides itself again. Aside from that it is working like it is suppose to, you just need to keep clicking the contact button to complete each step of the form process.

So far, based off of acrylian's suggestion I've come up with this:

function postback() { if(isset($_POST['sendmail'])) { document.getElementById('inquiry').style.visibility = 'visible'; } else { if (document.layers) { // Netscape 4 document.inquiry.visibility = 'visible'; } else { // IE 4 document.all.inquiry.style.visibility = 'visible'; } } }
But, so far I haven't had any luck. Is PHP not capable of telling a div to become visible if it is returning data from a form? Am I close to solving it with what I've written?

Administrator
Administrator
acrylian   2009-06-16, 18:52
#5

Well, you mixed JavaScript and PHP code. That will not work this way. You need to use CSS. Create two css classes for the div in your theme's css file, one visible and on invisible. Then use it in a similar way like if post echo '' else echo ' (this is not valid code!). Or use inline css to style the div.

Member
Member
joepinelli   2009-06-16, 21:00
#6

Thanks Acrylian. I don't know if I completely did what you were suggesting, but it is working. The div now stays up through the entire form process. I had to add an or statement for $_POST['confirm'])) as the confirmation would hide the div again. The "inquiry" id holds all the formating for my div. The "show" and "hide" classes are the visibility states set in my style sheet.

`

`
Any idea why there is a lag in receiving the emails and other times they just come right through? I'm guessing it's a hosting issue (using GoDaddy). Or maybe my email provider (Gmail)

Thanks again for your help!

Administrator
Administrator
acrylian   2009-06-17, 08:41
#7

Ok, I forgot the "confirm" part, it was out of memory. About the mail recieve issue I don't know, tests on my host worked fine. Maybe you get into a spam queue or something. The mail is sent via Zenphoto's internal mail functions that rely on the phpmail function installed on your server.

Update: I did a new test on my host and it worked fine.

Member
Member
Digifoto   2009-07-25, 14:50
#8

I experienced the lag too but it was the host in my case too. As soon as i switched the host the problem was solved. I used Hostgator

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.