I am trying to get the MLM subscribe form to be in a page/post on a wordpress blog. I am unsure how to get it to work correctly though. I have the following edited subscribe text in the wordpress page, but it seems that I don't know where to send the form to after the user hits submit... I would like for the form to run within the wordpress theme and page, without it having to send it to an external "subscribe_single_fixed.php" file.
UPDATE: "mysite.com/?page_id=711" is the wordpress page I have the subscribe form on, so I manually entered in the address bar:
and it gave me the correct "Sorry but we can’t process your request" meaning that the php worked... but I don't know how to get the form to send it correctly. I tried to enter the form action as:
but then it gave me this when I hit submit:
it took out "?page_id=711" completely and so it didn't work... how do I get it to add the correct string onto "?page_id=711" and not replace it first?
UPDATE 2: Ok, I switched the permalinks around and changed form action to "". It now displays the error messages correctly, but when I try to actually fill in the data, nothing happens. I think I have to change the url here:
but I'm not sure what to change it too. I tried typing in the absolute URL path to lm.php, but still nothing happens. I would like to have the confirmation still appear in the WordPress page.
UPDATE: "mysite.com/?page_id=711" is the wordpress page I have the subscribe form on, so I manually entered in the address bar:
Code:
mysite.com/?page_id=711?email=&firstname=&lastname=&list=list1&cmd=subscribe&submit=Submit
Code:
<form id="FormName" action="?page_id=711" method="get" name="FormName">
Code:
mysite.com/?email=&firstname=&lastname=&list=list1&cmd=subscribe&submit=Submit
UPDATE 2: Ok, I switched the permalinks around and changed form action to "". It now displays the error messages correctly, but when I try to actually fill in the data, nothing happens. I think I have to change the url here:
Code:
$url = "../lm.php";
Code:
<?php
$mlm_debug = False;
if ( $mlm_debug ) {
error_reporting(E_ALL);
ini_set('display_errors','on');
} else {
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors','off');
}
if ( isset( $_REQUEST['cmd'] ) && !empty( $_REQUEST['cmd'] ) ) { $cmd = $_REQUEST['cmd']; }
if ( isset( $_REQUEST['email'] ) && !empty( $_REQUEST['email'] ) ) { $email = $_REQUEST['email']; }
if ( isset( $_REQUEST['list'] ) && !empty( $_REQUEST['list'] ) ) { $list = $_REQUEST['list']; } else { $list = "list1"; }
if ( isset( $_REQUEST['firstname'] ) && !empty( $_REQUEST['firstname'] ) ) { $firstname = $_REQUEST['firstname']; }
if ( isset( $_REQUEST['lastname'] ) && !empty( $_REQUEST['lastname'] ) ) { $lastname = $_REQUEST['lastname']; }
if ( isset( $_REQUEST['submit'] ) ) {
$errors = array();
if ( $email == "" ) { $errors[] = "Enter your email address in the email address text box"; $wrong['email'] = TRUE; }
if ( $email !== "" && ( stristr( $email, "." ) == FALSE || stristr( $email, "@" ) == FALSE ) ) { $errors[] = "The e-mail address you have entered is not valid"; $wrong['email'] = TRUE; }
if ( $firstname == "" ) { $errors[] = "Enter your first name in the first name text box"; $wrong['firstname'] = TRUE; }
if ( $lastname == "" ) { $errors[] = "Enter your last name in the last name text box"; $wrong['lastname'] = TRUE; }
if ( count( $errors ) == 0 ) {
$url = "../lm.php";
$url .= "?cmd=$cmd&list=$list&email=$email&firstname=$firstname&lastname=$lastname";
header("Location: $url");
}
}
?>
<div align="center">
<br />
<br />
<table width="500" border="0" cellspacing="2" cellpadding="0">
<tr bgcolor="#000000" height="22">
<td height="22">
<div align="center">
<font color="#ff6600" face="Verdana, Arial, Helvetica, sans-serif"><b>Mailing List Subscription</b></font></div>
</td>
</tr>
<tr bgcolor="white" height="16">
<td height="16"></td>
</tr>
<tr>
<td>
<div align="center">
<form id="FormName" action=""" method="get" name="FormName">
<table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr height="24">
<td width="40%" height="24">
<div align="right">
<font size="-1" color="#ff9933" face="Verdana"><b>Your E-mail Address</b></font></div>
</td>
<td width="15" height="24"></td>
<td height="24"><input type="text" name="email" size="30" <?php echo " value=\"$email\""; ?> /></td>
<td height="24"><font size="-2" color="#ff0000" face="Geneva,Arial,Helvetica,sans-serif">Required</font></td>
</tr>
<tr height="24">
<td width="40%" height="24">
<div align="right">
<font size="-1" color="#ff9933" face="Verdana"><b>Your First Name</b></font></div>
</td>
<td width="15" height="24"></td>
<td height="24"><input type="text" name="firstname" size="30" <?php echo " value=\"$firstname\""; ?> /></td>
<td height="24"><font size="-2" color="#ff0000" face="Geneva,Arial,Helvetica,sans-serif">Required</font></td>
</tr>
<tr height="24">
<td width="40%" height="24">
<div align="right">
<font size="-1" color="#ff9933" face="Verdana"><b>Your Last Name</b></font></div>
</td>
<td width="15" height="24"></td>
<td height="24"><input type="text" name="lastname" size="30" <?php echo " value=\"$lastname\""; ?> /></td>
<td height="24"><font size="-2" color="#ff0000" face="Geneva,Arial,Helvetica,sans-serif">Required</font></td>
</tr>
<tr height="24">
<td width="40%" height="24">
<div align="right">
<input type="hidden" name="list" value="<?php echo $list; ?>" /></div>
</td>
<td width="15" height="24"></td>
<td height="24"><input type="radio" name="cmd" value="subscribe" <?php if ( $cmd == "" || $cmd == "subscribe" ) { echo "checked=\"checked\""; } ?> /><font size="2" face="Arial"> Subscribe <input type="radio" name="cmd" value="unsubscribe" <?php if ( $cmd == "unsubscribe" ) { echo "checked=\"checked\""; } ?> /> Unsubscribe</font></td>
<td height="24"></td>
</tr>
<tr height="20">
<td colspan="3" valign="top" height="20"></td>
<td valign="top" height="20"></td>
</tr>
<tr>
<td width="40%">
<div align="center"></div>
</td>
<td width="15"></td>
<td>
<div align="right">
<font size="-1" face="Verdana"><b><input type="submit" name="submit" value="Submit" /> <input type="reset" value="Clear Form" /></b></font></div>
</td>
<td></td>
</tr>
</table>
</form>
</div>
</td>
</tr>
<tr height="10">
<td height="10">
<div align="center">
<?php
// --- ERROR CHECKING ---
if ( isset( $_REQUEST['submit'] ) ) {
if ( count( $errors ) > 0) {
echo "<table width=\"500\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\">";
echo "<tr bgcolor=\"#ff0000\" height=\"22\">";
echo "<td height=\"22\">";
echo "<div align=\"center\">";
echo "<font color=\"white\" face=\"Verdana, Arial, Helvetica, sans-serif\"><b>Sorry but we can't process your request</b></font></div>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<font size=\"-1\" color=\"red\" face=\"Verdana, Arial, Helvetica, sans-serif\"\>";
echo "<b/>Please fix the following issues</b/><br />";
for($i=0; $i<count($errors); $i++){
echo $errors[$i]."<br />";
}
} else if ( count( $successes ) > 0) {
echo "<font color=\"blue\" face=\"Verdana, Arial, Helvetica, sans-serif\"\>";
echo "<b/>Your request has been processed successfully:</b/><br />";
for($i=0; $i<count($successes); $i++){
echo $successes[$i]."<br />";
}
}
}
?></div>
</td>
</tr>
</table>
<br />
<br />
</div>