Jump to content

Recommended Posts

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:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?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.</P>" );
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>");
}
}
?>[/quote]

i think the problem is in the last section
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?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>");
}
}
?>[/quote]
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

Link to comment
https://forums.phpfreaks.com/topic/5365-newsletter-signup-script-small-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.