Jump to content


Newsletter Signup Script Small Problem


  • Please log in to reply
3 replies to this topic

#1 Barty

Barty

    Advanced Member

  • Members
  • PipPipPip
  • 130 posts
  • Country:Uk

Posted 20 March 2006 - 07:48 PM

i am trying to create a small script for my blog, www.bartysblog.be where users can input their email address to signup for a newsletter or updates. the email address is stored in a database. the script byitself runs fine and stores the email in the database but when i copy to code into wordpress it doesnt work.
i think i know why but dont know how to fix it.
heres the code so far:

Quote

<?php

/**
*
*
* @version $Id$
* @copyright 2006
*/
$dbcnx = @mysql_connect("localhost", "bartyl_bartyl", "rudeboy");
if (!$dbcnx) {
echo( "<P>Unable to connect to the " .
"database server at this time." );
exit();
}
//Select Database here
if (! @mysql_select_db("bartyl_test") ) {
echo( "<P>Unable to locate the test " .
"database at this time.</P>" );
exit();
}
$result = mysql_query("SELECT Email FROM Users");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit();
}

?>
<FORM ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD=POST>
<P>Type your Email here:<BR>
<TEXTAREA name="email" style="width:200px" height:15px WRAP></TEXTAREA><BR>
<INPUT TYPE=SUBMIT NAME="submitjoke" VALUE="SUBMIT">
</FORM>


<?php
if ("SUBMIT" == $submitjoke) {
$sql = "INSERT INTO Users SET " .
"Email='$email', " .
" Date=CURDATE()";
if (mysql_query($sql)) {
echo("<P>Your Email has been added.</P>");
} else {
echo("<P>Error adding submitted joke: " .
mysql_error() . "</P>");
}
}
?>


i think the problem is in the last section

Quote

<?php
if ("SUBMIT" == $submitjoke) {
$sql = "INSERT INTO Users SET " .
"Email='$email', " .
"Date=CURDATE()";
if (mysql_query($sql)) {
echo("<P>Your Email has been added.</P>");
} else {
echo("<P>Error adding submitted joke: " .
mysql_error() . "</P>");
}
}
?>
the script only runs when the text, Your Email has been added is shown and in wordpress the text isnt shown. i need to change it so that the text doesnt need 2 run for the rest of the script to work
thanks in advance

#2 Barty

Barty

    Advanced Member

  • Members
  • PipPipPip
  • 130 posts
  • Country:Uk

Posted 20 March 2006 - 09:59 PM

Sorted, Radically Changed script!

#3 Neon

Neon

    Karl

  • Members
  • PipPipPipPipPipPip
  • 4,728 posts
  • Country:Space

Posted 21 March 2006 - 12:11 AM

Sorry i couldn't help :)

#4 ShadowFox

ShadowFox

    High Priest

  • Members
  • PipPipPipPipPipPip
  • 4,969 posts
  • Location:Tempe, AZ
  • Interests:An abundance :P
  • Country:United States

Posted 21 March 2006 - 12:19 AM

I'mm not a php magician I amm an HTML/ DHTML fanatic :) sorry, but good to hear you got it working :)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users