Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 14 Jul 2011, 01:20
thunderclap82 thunderclap82 is offline
 
Join Date: Dec 2008
Create PHP Email Submission

I'm trying to create a page that allows visitors to enter their email address to be added to a mailing list. I was going to just use the HTML <form>, but the 'mailto:' code keeps forcing email programs open, something that is messy and I don't want. Because of this I've elected to go with a PHP script instead.

Here is the code I have for the form itself:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I've tried putting this in a PHP Direct Evaluation page as well as a Static Page, but I just get errors.

I've tried creating a vB page as documented here but either the form php script is ignored or I get errors. Here is the vB page I created (called newslettersubscription.php):


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The form code I list previously I put in this page under YOUR CUSTOM CODE GOES HERE.

And with this file it calls a template, one I created called newsletter_subscription:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So any ideas what's going on? Either it doesn't display the form at all, or I get an error message, usually stating that an unknown command < is on such-a-such line.

Any help would be greatly appreciated.
Reply With Quote
  #2  
Old 14 Jul 2011, 01:36
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Try this: put the form php code in a php file (different from newslettersubscription.php, which you also need) and upload it to your server (form.lib.php has to be there too). Then create a new plugin using hook location global_start and this code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

(You can change 'formcode.php' to be whatever you named the file).

Then in your newsletter_subscription template, put {vb:raw mailform} where you want the form.

Last edited by kh99; 15 Jul 2011 at 19:00. Reason: fixed code
Reply With Quote
  #3  
Old 14 Jul 2011, 17:22
thunderclap82 thunderclap82 is offline
 
Join Date: Dec 2008
So here is my new code. First the page iteself (newslettersubscription.php):


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I then created the form.php file:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Then the template (newsletter_subscription):


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And finally the plugin (mailform):


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

When I try to load the page the page comes up, but no form.

Did I follow your directions correctly? I appreciate your help in this.

Last edited by thunderclap82; 14 Jul 2011 at 17:33.
Reply With Quote
  #4  
Old 14 Jul 2011, 17:29
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
There are a couple problems: one is that there was a typo in my post, in the plugin code it should be:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Also, you have to use the same variable name in the template that you used in the preRegister statement, so your template should have:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


...or else change the plugin code to be

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Last edited by kh99; 15 Jul 2011 at 19:00. Reason: fixed code
Reply With Quote
  #5  
Old 14 Jul 2011, 17:42
thunderclap82 thunderclap82 is offline
 
Join Date: Dec 2008
I spotted "mailform" as I posted, and edited my code accordingly.

But it still didn't work. The plugin (called MAILFORM):


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And I altered the template to be


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Still comes up blank. I assume by "variable" you mean the plugins title?

Also, when I activate the plugin it causes an error while Searching the forum.

Last edited by thunderclap82; 14 Jul 2011 at 17:47.
Reply With Quote
  #6  
Old 14 Jul 2011, 17:50
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
What you're doing should work, I think, but I just realized that there really is no reason to use a plugin, you could just put the plugin code in newslettersubscription.php, in the custom code section. And then you don't need to preRegister, you can just register like you're doing with the other variables. Sorry, I guess I was too tired last night to think straight.

Anyway, what I'd do next is see if $mailform has anything in it. You maybe could just echo() it then look at the page source (or maybe you'll just see it in the browser.
Reply With Quote
  #7  
Old 14 Jul 2011, 17:59
thunderclap82 thunderclap82 is offline
 
Join Date: Dec 2008
I thank you for trying. So I put the form.php code back into newslettersubscription.php and this is the error I get:

Parse error: syntax error, unexpected '<' in /home/fpaul46/public_html/forum/newslettersubscription.php on line 41

Here is the code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And this is line 41:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This is the very first line of the custom code. If I delete it I get this error:

Warning: require_once([path]form.lib.php) [function.require-once]: failed to open stream: No such file or directory in [path]/newslettersubscription.php on line 45

Fatal error: require_once() [function.require]: Failed opening required '/home/fpaul46/public_html/forumform.lib.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/fpaul46/public_html/forum/newslettersubscription.php on line 45
Reply With Quote
  #8  
Old 14 Jul 2011, 18:03
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Well, don't put the form code in newslettersubscription.php, put the code that you had in the plugin. (in fact you can leave the preRegister for now, there's no reason it shouldn't work).

Did you upload form.lib.php to the same directory with newslettersubscription.php?

At this point, maybe someone else has a better idea for you.
Reply With Quote
  #9  
Old 14 Jul 2011, 18:05
nhawk nhawk is offline
 
Join Date: Jan 2011
I hope I don't confuse things for you, but your entire form should be in the template being used (<form>...<div>...<input>...</div>...</form>... etc). Then when the submit button is clicked, send the data collected to the PHP file that processes it.
Reply With Quote
  #10  
Old 14 Jul 2011, 18:07
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by nhawk View Post
I hope I don't confuse things for you, but your entire form should be in the template being used (<form>...<div>...<input>...</div>...</form>... etc). Then when the submit button is clicked, send the data collected to the PHP file that processes it.
Yeah, that would be another way to do it, but since the form code has calls to php functions in it, I thought it would be easier to use the ob_start()...ob_end_clean() thing. If you put it all in a template you'd ahve to take out the php calls, assign them to variables, register them, etc.
Reply With Quote
  #11  
Old 14 Jul 2011, 18:20
thunderclap82 thunderclap82 is offline
 
Join Date: Dec 2008
Originally Posted by kh99 View Post
Well, don't put the form code in newslettersubscription.php, put the code that you had in the plugin. (in fact you can leave the preRegister for now, there's no reason it shouldn't work).

Did you upload form.lib.php to the same directory with newslettersubscription.php?

At this point, maybe someone else has a better idea for you.
Now I'm getting scattered brained. hehehe Bear with me.

So I disabled the plugin entirely and moved that code to newslettersubscription.php. I then add {vb:raw mailform} to the template.

Now the error is:

Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/fpaul46/public_html/forum/newslettersubscription.php on line 46

Line 46 is:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Not sure what I'm doing wrong. This is what happens when a non-programmer tries to do this. (Though in my defense, it doesn't seem like it should be this complicated.)
Reply With Quote
  #12  
Old 14 Jul 2011, 18:26
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by thunderclap82 View Post
Now the error is:

Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/fpaul46/public_html/forum/newslettersubscription.php on line 46

Line 46 is:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Not sure what I'm doing wrong. This is what happens when a non-programmer tries to do this. (Though in my defense, it doesn't seem like it should be this complicated.)
Yeah, that one's my fault again. it should be


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I copied and pasted that code from another thread where someone asked about it last night, but I guess I screwed it up. Sorry about that.

You're right, it shouldn't be this hard. I should have put the code together and tried it before posting, sorry.
Reply With Quote
  #13  
Old 14 Jul 2011, 18:27
thunderclap82 thunderclap82 is offline
 
Join Date: Dec 2008
That fixed it.

I really appreciate your help in this. Thank you so much!
Reply With Quote
  #14  
Old 14 Jul 2011, 18:28
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Is it actually working now? If it's not, don't give up - someone else here can probably help.
Reply With Quote
  #15  
Old 14 Jul 2011, 18:32
thunderclap82 thunderclap82 is offline
 
Join Date: Dec 2008
Originally Posted by kh99 View Post
Is it actually working now? If it's not, don't give up - someone else here can probably help.
I actually got a security token error, but I think that's a different problem. Time to Google...
Reply With Quote
Reply



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

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


New To Site? Need Help?

All times are GMT. The time now is 07:48.

Layout Options | Width: Wide Color: