Go Back   Novahq.net Forum > phphq.Net > phphq.Net Forums
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-18-2010, 01:12 AM
Dylan is offline Dylan
Registered User

Join Date: Dec 2010
Posts: 2

phmailer Problems When Embedded in a Page

I embedded phmailer in an HTML page. Everything works flawlessly, with one exception. When I try to submit an E-Mail that has an incomplete field or other error it amends the page and shows that I have errors in a big red text, but it navigates away from the page and goes to the phmailer.php file to do so. I poked and prodded to try to figure out what makes this tick; it all seems like magic to me.

What I'd like it to do is just use JavaScript alert to tell the submitter there's a problem, without navigating away (I'm not sure how it works, but I think it tries to reload itself). I can get the alert down, but it still moves from the current page to just the lone php page.

If I'm explaining this poorly please let me know. My code is a mess and all over the place. The phpmailer page has not been greatly altered though.
Reply With Quote
  #2  
Old 12-18-2010, 08:39 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,922

How did you embed it? Did you just copy the phMailer form html and then direct your form to phMailer.php? Or did you use a frame or what? A link would help.
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #3  
Old 12-18-2010, 04:13 PM
Dylan is offline Dylan
Registered User

Join Date: Dec 2010
Posts: 2

I can't seem to find the exact page, but I was looking around for ways to embed a PHP page into an HTML page. I know there are better, more orthodox ways of doing these things, but I'm no pro - I like to just tinker. Someone wanted to put a PHP-based clock into their page and I adapted that to load the mailing form. Basically it used JavaScript to run a function that loads the page into a div.

Here's the JS code:

Code:
 
var urlForPHP 			= "test.php";
var idForReplace		= "contact-area";
 
var xmlhttp;
 
function reloadPHP()
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your Browser does not support HTTP Request");
		return;
	}
	var url=urlForPHP;
	url=url+"?random="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
 
function stateChanged()
{
	if (xmlhttp.readyState==4)
	{
	document.getElementById(idForReplace).innerHTML=xmlhttp.responseText;
	}
}
 
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
Where "test.php" is the mailer here, and "contact-area" is the div it is loaded into. The page this is all on is an HTML page. I tried keeping the whole of the "site" on one page and had the contents of various pages load into a section of it rather than navigate away. In hindsight, it probably wasn't worth the aggravation.

Maybe it's this code that's doing it.
Reply With Quote
  #4  
Old 12-18-2010, 05:41 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,922

That is a tricky one. More than likely, when you load up the php form in your html page, it does not refresh the DOM with the phMailers JavaScript. If you take out the JavaScript in my form and include it on the HTML page, it might work. However, for errors such as wrong file types and uploaded files being to big, it will still have the red text because JavaScript is only client side so it does not know the response of the server.

Maybe you could use a inline frame? Or change the HTML within the phMailer file to reflect your websites design.
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PhMailer: help xist phphq.Net Forums 0 05-19-2008 04:07 PM
phMailer k1200lt phphq.Net Forums 4 12-11-2007 12:02 AM
Open text from page in another page katana*GFR* Web design and Programming 21 07-21-2005 10:28 AM
<Previous page 1 2 3 4 5 6 next page> script big n00b at php phphq.Net Forums 4 03-11-2005 12:35 PM
embedded animated sigs??? BOne Sigs and Graphics 5 09-28-2004 06:37 PM


All times are GMT -5. The time now is 10:12 AM.




Powered by vBulletin®