Email sign up box?

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post January 5th, 2007, 6:56 pm

Is that "Goods Cams" or "Good Scams" ?
Strong with this one, the sudo is.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 5th, 2007, 6:56 pm

  • Tchuki
  • Mastermind
  • Mastermind
  • No Avatar
  • Joined: Sep 30, 2004
  • Posts: 1774
  • Loc: Edinburgh
  • Status: Offline

Post January 5th, 2007, 6:58 pm

##--[ FIND ]--##
PHP Code: [ Select ]
$db = mysql_connect("$localhost", "$str", "$str")
 
 
 
or die ("Error connecting to database.");
 
 
 
$connect = mysql_select_db("$str", $db)
 
 
 
or die ("Couldn't select the database.");
  1. $db = mysql_connect("$localhost", "$str", "$str")
  2.  
  3.  
  4.  
  5. or die ("Error connecting to database.");
  6.  
  7.  
  8.  
  9. $connect = mysql_select_db("$str", $db)
  10.  
  11.  
  12.  
  13. or die ("Couldn't select the database.");



##--[ REPLACE WITH ]--##
PHP Code: [ Select ]
$db  =  mysql_connect("$db_host",  "$db_user",  "$db_pass")
 
        or  die  ("Error  connecting  to  database.");
 
       
 
$connect  =  mysql_select_db("$db_name",  $db)
 
        or  die  ("Couldn't  select  the  database.");
  1. $db  =  mysql_connect("$db_host",  "$db_user",  "$db_pass")
  2.  
  3.         or  die  ("Error  connecting  to  database.");
  4.  
  5.        
  6.  
  7. $connect  =  mysql_select_db("$db_name",  $db)
  8.  
  9.         or  die  ("Couldn't  select  the  database.");


You dont need to edit the REPLACE WITH code, the first four variables of the PHP code are "pointers" for that code.
  • Tchuki
  • Mastermind
  • Mastermind
  • No Avatar
  • Joined: Sep 30, 2004
  • Posts: 1774
  • Loc: Edinburgh
  • Status: Offline

Post January 5th, 2007, 6:59 pm

joebert wrote:
Is that "Goods Cams" or "Good Scams" ?


Must admit, that has crossed my mind aswell :wink:
  • goodscams
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 05, 2007
  • Posts: 13
  • Status: Offline

Post January 6th, 2007, 9:37 am

changed the { five lines up for ;

now get

Could not insert new data : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'addresses (email, name) VALUES ('aca@hotmail.com', 'g')' at line 1

Thanks for your help

Its Good scams, I like to abuse the supermarkets when i can with scams, legitimate I may add

cheers
  • Tchuki
  • Mastermind
  • Mastermind
  • No Avatar
  • Joined: Sep 30, 2004
  • Posts: 1774
  • Loc: Edinburgh
  • Status: Offline

Post January 6th, 2007, 12:31 pm

Hmm, Syntax error:


##--[ FIND ]--##

PHP Code: [ Select ]
 
if(!empty($email) && (!empty($name))) {
 
$query = mysql_query("INSERT INTO email addresses (email, name) VALUES ('$email', '$name')")
 
or die ("Could not insert new data : " . mysql_error());
 
 
 
echo ("THANKS FOR YOUR SUBMISSION !");
  1.  
  2. if(!empty($email) && (!empty($name))) {
  3.  
  4. $query = mysql_query("INSERT INTO email addresses (email, name) VALUES ('$email', '$name')")
  5.  
  6. or die ("Could not insert new data : " . mysql_error());
  7.  
  8.  
  9.  
  10. echo ("THANKS FOR YOUR SUBMISSION !");



##--[ REPLACE WITH ]--##

PHP Code: [ Select ]
 
if(!empty($email) && (!empty($name))) {
 
 
 
$query = mysql_query("INSERT INTO email addresses (email, name) VALUES ('$email', '$name')")
 
or die ("Could not insert new data : " . mysql_error());
 
 
 
echo ("THANKS FOR YOUR SUBMISSION !");
 
 
 
}
  1.  
  2. if(!empty($email) && (!empty($name))) {
  3.  
  4.  
  5.  
  6. $query = mysql_query("INSERT INTO email addresses (email, name) VALUES ('$email', '$name')")
  7.  
  8. or die ("Could not insert new data : " . mysql_error());
  9.  
  10.  
  11.  
  12. echo ("THANKS FOR YOUR SUBMISSION !");
  13.  
  14.  
  15.  
  16. }
  • goodscams
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 05, 2007
  • Posts: 13
  • Status: Offline

Post January 6th, 2007, 1:40 pm

getting there it just says

Could not insert new data : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'addresses (email, name) VALUES ('aca@hotmail.com', 'G')' at line 1


Is it maybe the code i used in SQL rather than PHP bit?

Thanks in advance
  • Tchuki
  • Mastermind
  • Mastermind
  • No Avatar
  • Joined: Sep 30, 2004
  • Posts: 1774
  • Loc: Edinburgh
  • Status: Offline

Post January 6th, 2007, 1:50 pm

Nah mate, its me being a muppet and not checking my syntax before making a post.


##--[ FIND IN LINE ]--##
PHP Code: [ Select ]
email addresses


##--[ REPLACE IN LINE WITH ]--##
PHP Code: [ Select ]
email_addresses



^^ or what ever you have named your DB, but make sure it has no spaces in it, spaces should be replaced by an underscore character.
  • goodscams
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 05, 2007
  • Posts: 13
  • Status: Offline

Post January 6th, 2007, 1:58 pm

Can't quite see where you mean this is what I have now, Thanks

<?PHP

$db_host = 'localhost';
$db_user = 'th';
$db_name = 'STR';
$db_pass = 'a7';

$db = mysql_connect("$db_host", "$db_user", "$db_pass")
or die ("Error connecting to database.");

$connect = mysql_select_db("$db_name", $db)
or die ("Couldn't select the database.");


$email = $_POST['email'];
$name = $_POST['name'];

if(!empty($email) && (!empty($name))) {

$query = mysql_query("INSERT INTO email addresses (email, name) VALUES ('$email', '$name')")
or die ("Could not insert new data : " . mysql_error());

echo ("THANKS FOR YOUR SUBMISSION !");

}

?>
  • Tchuki
  • Mastermind
  • Mastermind
  • No Avatar
  • Joined: Sep 30, 2004
  • Posts: 1774
  • Loc: Edinburgh
  • Status: Offline

Post January 6th, 2007, 2:06 pm

Replace your code with the following:

PHP Code: [ Select ]
<?PHP
 
 
 
$db_host = 'localhost';
 
 
 
$db_user = 'th';
 
 
 
$db_name = 'STR';
 
 
 
$db_pass = 'a7';
 
 
 
$db = mysql_connect("$db_host", "$db_user", "$db_pass")
 
 
 
or die ("Error connecting to database.");
 
 
 
$connect = mysql_select_db("$db_name", $db)
 
 
 
or die ("Couldn't select the database.");
 
 
 
$email = $_POST['email'];
 
 
 
$name = $_POST['name'];
 
 
 
if(!empty($email) && (!empty($name))) {
 
 
 
$query = mysql_query("INSERT INTO email_addresses (email, name) VALUES ('$email', '$name')")
 
 
 
or die ("Could not insert new data : " . mysql_error());
 
 
 
echo ("THANKS FOR YOUR SUBMISSION !");
 
 
 
}
 
 
 
?>
  1. <?PHP
  2.  
  3.  
  4.  
  5. $db_host = 'localhost';
  6.  
  7.  
  8.  
  9. $db_user = 'th';
  10.  
  11.  
  12.  
  13. $db_name = 'STR';
  14.  
  15.  
  16.  
  17. $db_pass = 'a7';
  18.  
  19.  
  20.  
  21. $db = mysql_connect("$db_host", "$db_user", "$db_pass")
  22.  
  23.  
  24.  
  25. or die ("Error connecting to database.");
  26.  
  27.  
  28.  
  29. $connect = mysql_select_db("$db_name", $db)
  30.  
  31.  
  32.  
  33. or die ("Couldn't select the database.");
  34.  
  35.  
  36.  
  37. $email = $_POST['email'];
  38.  
  39.  
  40.  
  41. $name = $_POST['name'];
  42.  
  43.  
  44.  
  45. if(!empty($email) && (!empty($name))) {
  46.  
  47.  
  48.  
  49. $query = mysql_query("INSERT INTO email_addresses (email, name) VALUES ('$email', '$name')")
  50.  
  51.  
  52.  
  53. or die ("Could not insert new data : " . mysql_error());
  54.  
  55.  
  56.  
  57. echo ("THANKS FOR YOUR SUBMISSION !");
  58.  
  59.  
  60.  
  61. }
  62.  
  63.  
  64.  
  65. ?>


Note the line:

PHP Code: [ Select ]
$query = mysql_query("INSERT INTO email_addresses (email, name) VALUES ('$email', '$name')")
and that the table name now contains an underscore instead of white space. You will need to change your table name accoringly in your DB as well.
  • goodscams
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 05, 2007
  • Posts: 13
  • Status: Offline

Post January 6th, 2007, 3:37 pm

WOW it works, thank you very very much

how do i get the HTML table to be small table as part of an existing web page rather than one page in itself?

Thanks
  • Tchuki
  • Mastermind
  • Mastermind
  • No Avatar
  • Joined: Sep 30, 2004
  • Posts: 1774
  • Loc: Edinburgh
  • Status: Offline

Post January 6th, 2007, 4:07 pm

Paste:

Code: [ Select ]
<form name="emails" action="process.php" method="post">

<table>

<tr>

<td>Email:</td>

<td><input type="text" name="email" /></td>

</tr>

<tr>

<td>Name:</td>

<td><input type="text" name="name" /></td>

</tr>

</table>

</form>
  1. <form name="emails" action="process.php" method="post">
  2. <table>
  3. <tr>
  4. <td>Email:</td>
  5. <td><input type="text" name="email" /></td>
  6. </tr>
  7. <tr>
  8. <td>Name:</td>
  9. <td><input type="text" name="name" /></td>
  10. </tr>
  11. </table>
  12. </form>


Where ever you want the email form to appear on your page, so just add it to your HTML page somewhere.

Sorry it took so long to get it to work, if I had checked my syntax the first time [ which I should have ] it would have been working a lot quicker,
  • goodscams
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 05, 2007
  • Posts: 13
  • Status: Offline

Post January 6th, 2007, 6:08 pm

Thanks Tchuki for all your help
  • TonyMatt1
  • Born
  • Born
  • No Avatar
  • Joined: Jan 03, 2011
  • Posts: 1
  • Status: Offline

Post January 3rd, 2011, 10:59 am

Hi,

Reviving an oldie I guess...

I came across this thread which is very helpful. This helped me start to learn php, so it's a little at a time.

This code works for me but I do have a couple questions if someone here may be able to help.

If an email is not submitted or it is not proper, and someone clicks the submit button, the thank you page still shows up, it is blank (without the thank you). I am trying to figure out how to get that page to state there is an error and to please try again.

If anyone can offer some help, it would be appreciated.

Thank you,
Tony M

Post Information

  • Total Posts in this topic: 28 posts
  • Users browsing this forum: No registered users and 180 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.