Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
proper PHP form-setup
Old 03-16-2009, 04:50 AM proper PHP form-setup
Candyman87's Avatar
Experienced Talker

Posts: 42
Name: Mike
Trades: 0
Hello guys,

I'm working on my first real website and I'm wondering how I can setup my PHP contact form that I only collect the email address of the sender if the person checkmarks a box called "subscribe to my mailing list".

I have this box, I have setup my PHPMyAdmin settings, everything works well but I don't want to send people news that don't want to receive any...

Here's the link of the forms, if you want I can also provide any source code of the documents!

http://www.virtual-oz.com/html/contact.html


Muchos besos in advance!
C@ndy
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE

Last edited by Candyman87; 03-16-2009 at 04:52 AM..
Candyman87 is offline
Reply With Quote
View Public Profile Visit Candyman87's homepage!
 
 
Register now for full access!
Old 03-16-2009, 06:04 AM Re: proper PHP form-setup
dark_lord's Avatar
Experienced Talker

Posts: 41
Name: Parijat Roy
Location: INDIA-KOLKATA
Trades: 0
you should put one column in database table where you are storing the email-ids. name it is epref and put default value as 1 and when someone says no emails then set that column as 0.

Now while sending emails you use this database query

PHP Code:
$results mysql_query("SELECT email FROM table_name WHERE epref!='0'"); 
while(
$result mysql_fetch_array($results))
{
           
mail($result[0]......) ; // default mail function to send mail through php

this will help only send emails who wants
__________________
I AM THE BEAUTIFUL NIGHTMARE

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
dark_lord is offline
Reply With Quote
View Public Profile Visit dark_lord's homepage!
 
Old 03-16-2009, 04:25 PM Re: proper PHP form-setup
Candyman87's Avatar
Experienced Talker

Posts: 42
Name: Mike
Trades: 0
Quote:
Originally Posted by dark_lord View Post
you should put one column in database table where you are storing the email-ids. name it is epref and put default value as 1 and when someone says no emails then set that column as 0.
Hello Dark_Lord!

Thank you for your response it's just that I didn't understand well WHERE I have to add this code... (I'm completely new to PHP)

my PHP contact form is embed on the HTML page through an iFrame. So... does that mean I have to edit the basic PHP form behind? If you want I can send you the PHP file also. I will try to send you a private message with my email address...
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
Candyman87 is offline
Reply With Quote
View Public Profile Visit Candyman87's homepage!
 
Old 03-16-2009, 06:13 PM Re: proper PHP form-setup
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
On http://www.virtual-oz.com/forms_admin/formbwf.php , you can tell if they have checked the box in your PHP code with

PHP Code:
if (isset($_POST['Subscribe_to_newsletter'])) {
 
//Do what you want.

From your first post, you only want to store their information if this box is checked, so just put your database storage code or email routine (if emailing this to yourself instead of saving in a database) inside of the { and }.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 03-16-2009, 09:17 PM Re: proper PHP form-setup
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
As far as I can see from the PM code you sent me,
PHP Code:
if (preg_match ("/^yes$/i",$send_emails)){ 
needs to be changed to

PHP Code:
if (preg_match ("/^yes$/i",$send_emails) && isset($_POST['Subscribe_to_newsletter'])){ 
That will completely ignore the form unless the user registers for your newsletter.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 03-16-2009, 10:52 PM Re: proper PHP form-setup
Candyman87's Avatar
Experienced Talker

Posts: 42
Name: Mike
Trades: 0
Quote:
Originally Posted by JeremyMiller View Post
...

That will completely ignore the form unless the user registers for your newsletter.
Hello Jeremy,

thank you for your effort BUT I want to set up the form so that only the people who confirm that they want to be on my mailing list will be added to my database. Nothing more!
The form and the database are working perfectly!
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
Candyman87 is offline
Reply With Quote
View Public Profile Visit Candyman87's homepage!
 
Old 03-17-2009, 03:45 AM Re: proper PHP form-setup
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Your bolded text is why I did things the way I did -- nothing happens unless they check the box. You'll have to phrase it differently if I'm not seeing what you were looking to do.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 03-17-2009, 05:26 AM Re: proper PHP form-setup
Candyman87's Avatar
Experienced Talker

Posts: 42
Name: Mike
Trades: 0
I'm sorry if I wasn't clear in my phrase.

That's how I want it to work:

When you click on send/submit (with or without the marked checkbox) the email will be sent to my inbox "independently".

-if the mailinglist box IS CHECKED it will also add the sender's address to my database

-if the mailinglist box IS NOT CHECKED than it will only send me the email, but the address won't be added automatically to the database

(The default value of the box is checked...)
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE

Last edited by Candyman87; 03-19-2009 at 08:57 PM.. Reason: add more clarity to this post.
Candyman87 is offline
Reply With Quote
View Public Profile Visit Candyman87's homepage!
 
Old 03-20-2009, 07:35 PM Re: proper PHP form-setup
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Finally got a chance to take another look. PLEASE TEST THE FOLLOWING BEFORE ASSUMING IT WORKS.

Change all instances of
PHP Code:
if( $GLOBALS['IS_DB_OK'] ) db_bwf_insert( ); 
to
PHP Code:
if( $GLOBALS['IS_DB_OK'] && isset($_POST['Subscribe_to_newsletter'])) db_bwf_insert( ); 
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 03-21-2009, 01:33 AM Re: proper PHP form-setup
Candyman87's Avatar
Experienced Talker

Posts: 42
Name: Mike
Trades: 0
Quote:
Originally Posted by JeremyMiller View Post
Finally got a chance to take another look. PLEASE TEST THE FOLLOWING BEFORE ASSUMING IT WORKS.

Change all instances of
PHP Code:
if( $GLOBALS['IS_DB_OK'] ) db_bwf_insert( ); 
to
PHP Code:
if( $GLOBALS['IS_DB_OK'] && isset($_POST['Subscribe_to_newsletter'])) db_bwf_insert( ); 
JEREMY and ROY YOU ARE GREAT!!!!

It's working now!!!!

Thank you so much!

I don't have much to offer but I'd be glad to send you some songs once I'm finished with editing them (of course only if you want...).

of course from now you and anybody else can also subscribe to my finally working mailing list --> www.virtual-oz.com

PEACE OUT!
C@ndy
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE

Last edited by Candyman87; 03-21-2009 at 01:56 AM..
Candyman87 is offline
Reply With Quote
View Public Profile Visit Candyman87's homepage!
 
Old 03-21-2009, 03:27 AM Re: proper PHP form-setup
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Glad you got it working. As for a reward, TK is always appreciated. Thanks for letting us know that the problem is resolved.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 03-22-2009, 09:51 AM Re: proper PHP form-setup
dark_lord's Avatar
Experienced Talker

Posts: 41
Name: Parijat Roy
Location: INDIA-KOLKATA
Trades: 0
I'm also glad that it finally worked out.

And We will be waiting for your songs
__________________
I AM THE BEAUTIFUL NIGHTMARE

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
dark_lord is offline
Reply With Quote
View Public Profile Visit dark_lord's homepage!
 
Reply     « Reply to proper PHP form-setup
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.40128 seconds with 12 queries