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
Phplist - signup form on website, not separate page.
Old 05-11-2009, 12:48 PM Phplist - signup form on website, not separate page.
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
How do I do this? I want a simple form on my website where people can sign up to our emailing list, using phplist. Right now I just have a link to their page they set up for you... when I want a form.

Here's the website I'm working on.
www.polkadotrefugees.com

Thanks for your help!
__________________
Check out my portfolio:

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

And my tech blog:
Please login or register to view this content. Registration is FREE
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
 
Register now for full access!
Old 05-11-2009, 03:52 PM Re: Phplist - signup form on website, not separate page.
Extreme Talker

Posts: 177
Trades: 0
I would have a database table for the email list that stores everyone that wants to be on the list.

So the form would look something like...
HTML Code:
<form action="email_signup.php" method="POST">
<input type="text" name="email">
<input type=submit" value="sign me up baby!">
</form>
then on the post page

PHP Code:
$mail $_POST['email'];
// I'm not gonna write it, Google searches will quickly give the result but...
// validate email by making sure it's a valid email format
// make sure this email already isn't in the database table, this can actually //be done by restricting the email field in the table to be unique, then the //insert statement will just fail if that email is already on the list
// if this all passes...then....
$insert "INSERT INTO email_list (email) VALUES ('$email')";
if(!
mysql_query($insert))
{
 echo 
"failed to add to mailing list";
}
else
{
echo 
"Email added to mailing list!";

It would be something similar to that.

Last edited by kbfirebreather; 05-11-2009 at 03:52 PM.. Reason: fixed my insert statement
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-11-2009, 10:33 PM Re: Phplist - signup form on website, not separate page.
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
Ok I found a php validation code... here's what I have.

PHP Code:
$mail $_POST['email'];
$email 'test@domain.com';

if(
verify_email($email)){

    
// E-mail address looks to be in the proper format
    // lets check the MX records

    
if(verify_email_dns($email)){

        
// E-mail passed both checks
        
echo 'Success - E-mail address appears to be valid.';

    } else {

        
// E-mail is invalid, no MC record
        
echo 'Error - E-mail domain does not have an MX record.';

    }

} else {

    
// E-mail inst formatted correctly
    // so we don't even check its MX record
    
echo 'Error - E-mail address appears to be invalid.';

}

// Our function to filter our bogus formatted addresses
function verify_email($email){

    if(!
preg_match('/^[_A-z0-9-]+((\.|\+)[_A-z0-9-]+)*@[A-z0-9-]+(\.[A-z0-9-]+)*(\.[A-z]{2,4})$/',$email)){
        return 
false;
    } else {
        return 
$email;
    }
}

// Our function to verify the MX records
function verify_email_dns($email){

    
// This will split the email into its front
    // and back (the domain) portions
    
list($name$domain) = split('@',$email);

    if(!
checkdnsrr($domain,'MX')){

        
// No MX record found
        
return false;

    } else {

        
// MX record found, return email
        
return $email;

    }
}
$insert "INSERT INTO email_list (email) VALUES ('$email')";
if(!
mysql_query($insert))
{
 echo 
"failed to add to mailing list";
}
else
{
echo 
"Email added to mailing list!";

Will this all work together? Also, wouldn't I have to put the mysql database name, username, and password somewhere? Where would I put that, if I have to? Thanks for the help!
__________________
Check out my portfolio:

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

And my tech blog:
Please login or register to view this content. Registration is FREE
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
Old 05-12-2009, 12:53 PM Re: Phplist - signup form on website, not separate page.
Extreme Talker

Posts: 177
Trades: 0
Theoretically it should work. And yes, you are correct, you would need a connect statement at the top of the page, connecting to the database.

http://us3.php.net/function.mysql-connect

Well technically, you would just have to connect to the database before you execute any queries (insert in this case)
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-12-2009, 02:28 PM Re: Phplist - signup form on website, not separate page.
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
Ugh, I give up. Nothing works. I have no idea what I'm doing. I spent a good 45 minutes fumbling around. >_<

Php makes no sense to me..
__________________
Check out my portfolio:

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

And my tech blog:
Please login or register to view this content. Registration is FREE
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
Old 05-12-2009, 02:34 PM Re: Phplist - signup form on website, not separate page.
Extreme Talker

Posts: 177
Trades: 0
do you have a php server? do you have a mysql server? or are you using xampp or something like that?

Can you not connect to the database?

Do you have a database created with tables in them?

php is a really friendly "loose" language that isn't entirely too picky.

I'm more then willing to assist you further if you wanted to post your code or tell us where you're getting your errors. I'm also here at work for 5 more hours, and my works consists of me sitting at a computer and doing what ever I want to do...since calls are always scarce.

And I am pretty bored, so lay it on me
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-12-2009, 02:47 PM Re: Phplist - signup form on website, not separate page.
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
Thanks for your patience, I just freaked out for a second there... the world needs more people like you.

Ok. So, I have this page:
http://polkadotrefugees.com/email_signup.php
And on http://polkadotrefugees.com/ I have the form. It connects to the database, and it can verify the email address properly, but I get a couple of errors in which I have no idea what they mean..
PHP Code:
<?php
$link 
mysql_connect('localhost''mydatabase_user''mydatabase_pass');
if (!
$link) {
    die(
'Could not connect: ' mysql_error());
}
echo 
'Connected successfully';
mysql_close($link);


$mail $_POST['email'];


if(
verify_email($email)){

    
// E-mail address looks to be in the proper format
    // lets check the MX records

    
if(verify_email_dns($email)){

        
// E-mail passed both checks
        
echo 'Success - E-mail address appears to be valid.';

    } else {

        
// E-mail is invalid, no MC record
        
echo 'Error - E-mail domain does not have an MX record.';

    }

} else {

    
// E-mail inst formatted correctly
    // so we don't even check its MX record
    
echo 'Error - E-mail address appears to be invalid.';

}

// Our function to filter our bogus formatted addresses
function verify_email($email){

    if(!
preg_match('/^[_A-z0-9-]+((\.|\+)[_A-z0-9-]+)*@[A-z0-9-]+(\.[A-z0-9-]+)*(\.[A-z]{2,4})$/',$email)){
        return 
false;
    } else {
        return 
$email;
    }
}

// Our function to verify the MX records
function verify_email_dns($email){

    
// This will split the email into its front
    // and back (the domain) portions
    
list($name$domain) = split('@',$email);

    if(!
checkdnsrr($domain,'MX')){

        
// No MX record found
        
return false;

    } else {

        
// MX record found, return email
        
return $email;

    }
}
$insert "INSERT INTO mydatabase_name (email) VALUES ('$email')";
if(!
mysql_query($insert))
{
 echo 
"failed to add to mailing list";
}
else
{
echo 
"Email added to mailing list!";
}  
?>
Edit: Oh, here's the errors:
Code:

Warning:  mysql_query() [function.mysql-query]: Access denied for user 'endeavor'@'localhost' (using password: NO) in /home/endeavor/public_html/polkadotrefugees/email_signup.php on line 68

Warning:  mysql_query() [function.mysql-query]: A link to the server could not be established in /home/endeavor/public_html/polkadotrefugees/email_signup.php on line 68
Well, I guess I know what they mean, but I don't know how I could fix them. I do have a PHP server. Before all of those errors though, I do see "Connected successfully", so... it's strange.
__________________
Check out my portfolio:

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

And my tech blog:
Please login or register to view this content. Registration is FREE

Last edited by 1nteresting; 05-12-2009 at 02:57 PM..
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
Old 05-12-2009, 03:08 PM Re: Phplist - signup form on website, not separate page.
Extreme Talker

Posts: 177
Trades: 0
Ok I think this is actually a pretty simple fix. Obviously your connect statement isn't failing because it echo's connected successfully.

But right after that you are closing connection via (mysql_close($link)), so when you try and execute the queries below you have no service to the database.

So I'm confident the only thing you need to do is take out the line
PHP Code:
mysql_close($link); 
and honestly, you don't need that anywhere on your page. As soon as all scripts are done running (the page loads) it automatically disconnects from the server (equivalent to closing it yourself)
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-12-2009, 03:59 PM Re: Phplist - signup form on website, not separate page.
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
Cool! That got rid of the errors, but there's still one more thing that's being goofy...

"failed to add to mailing list"
__________________
Check out my portfolio:

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

And my tech blog:
Please login or register to view this content. Registration is FREE
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
Old 05-12-2009, 04:07 PM Re: Phplist - signup form on website, not separate page.
Extreme Talker

Posts: 177
Trades: 0
change
PHP Code:
if(!mysql_query($insert))
{
 echo 
"failed to add to mailing list";
}
else
{
echo 
"Email added to mailing list!";

to

PHP Code:
if(!mysql_query($insert))
{
die(
"failed to add to mailing list, insert-> $insert :: error-> " mysql_error());
}
else
{
echo 
"Email added to mailing list!";

And then post the output of what die() is printint out.
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-12-2009, 05:24 PM Re: Phplist - signup form on website, not separate page.
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
Here's the result.
Code:
Connected successfullySuccess - E-mail address appears to be valid.failed to add to mailing list, insert-> INSERT INTO endeavor_polkamaillist (email) VALUES ('testing@domain.com') :: error-> No database selected
__________________
Check out my portfolio:

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

And my tech blog:
Please login or register to view this content. Registration is FREE
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
Old 05-12-2009, 05:42 PM Re: Phplist - signup form on website, not separate page.
Extreme Talker

Posts: 177
Trades: 0
ahh yes...after the connect you need to select the database that the table is in for the insert statement.

http://us3.php.net/mysql_select_db

that page has a good example of the whole procedure, with connection and selection of database.
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-12-2009, 08:18 PM Re: Phplist - signup form on website, not separate page.
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
Alrighty, this is what it spits out. It's a little different..I mean, it has more information on to what the problem is.

Code:
Success - E-mail address appears to be valid.failed to add to mailing list, insert-> INSERT INTO email (email) VALUES ('testing@domain.com') :: error-> Unknown column 'email' in 'field list'
__________________
Check out my portfolio:

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

And my tech blog:
Please login or register to view this content. Registration is FREE
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
Old 05-12-2009, 08:22 PM Re: Phplist - signup form on website, not separate page.
Extreme Talker

Posts: 177
Trades: 0
that just means you don't have a field named 'email' in teh table 'email_list'
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-12-2009, 09:20 PM Re: Phplist - signup form on website, not separate page.
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
Which... to create one I would use this code?

PHP Code:
<?php
// Make a MySQL Connection
mysql_connect("localhost""database_user""database_pass") or die(mysql_error());
mysql_select_db("my_databasename") or die(mysql_error());

// Create a MySQL table in the selected database
mysql_query("CREATE TABLE email(
id INT NOT NULL AUTO_INCREMENT, 
PRIMARY KEY(id),
 name VARCHAR(30), 
 age INT)"
)
 or die(
mysql_error());  

echo 
"Table Created!";

?>
__________________
Check out my portfolio:

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

And my tech blog:
Please login or register to view this content. Registration is FREE
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
Old 05-12-2009, 09:31 PM Re: Phplist - signup form on website, not separate page.
Extreme Talker

Posts: 177
Trades: 0
You only need to create the table once. then you can insert to it as much as you want
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-12-2009, 10:21 PM Re: Phplist - signup form on website, not separate page.
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
How do I create a field...
__________________
Check out my portfolio:

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

And my tech blog:
Please login or register to view this content. Registration is FREE
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
Old 05-12-2009, 10:29 PM Re: Phplist - signup form on website, not separate page.
Extreme Talker

Posts: 177
Trades: 0
that's from the create table statement

mysql code:
Code:
create table (
field_name1 field_attributes1,
field_name2 field_attributes2,
etc.
);
do you have access to phpmyadmin?
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-12-2009, 10:39 PM Re: Phplist - signup form on website, not separate page.
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
Alright man, thanks for the help... I'm going to take a break from it for now. I really appreciate your patience.

It's not worth the effort that both you and I are putting into it, people can just sign up at the templated page. Phplist says nothing about forms on websites, so I don't even know if it's possible.

Thanks again.
__________________
Check out my portfolio:

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

And my tech blog:
Please login or register to view this content. Registration is FREE
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
Reply     « Reply to Phplist - signup form on website, not separate page.
 

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.56513 seconds with 12 queries