Hi i am trying to create a form in a snippet. and i want to insert the values in the database . I dont know why the values are not saving .
Given below is all the code of the snippet. i dont know when the form is submitted why it does not go inside the condition if($_POST[’name11’]!=null)
<?php
$timee = time();
$DBhost = "localhost"; // your mysql server...
$DBuser = "modx"; // your mysql login
$DBpass = "modx";
$DBName = "calender"; // the name of the database used
// Connect
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
mysql_select_db("$DBName") or die("Doh!");
$varsquery = "SELECT * FROM cal_vars WHERE ID = ’1’";
$varsresult = mysql_query($varsquery);
$vars = mysql_fetch_array($varsresult);
print "<TABLE BORDER=0 CELLPADDING=10 CELLSPACING=0 WIDTH=100%>";
print "<TR><TD ALIGN=center>";
print "<TABLE BORDER=1 CELLPADDING=6 BORDERCOLOR=#000000 WIDTH=500 CELLSPACING=0>";
print "<TR><TD BGCOLOR=#CCCCCC colspan=2><B><FONT SIZE=3>Subscribe to newsletter";
print "</TR>";
print "<TR><TD COLSPAN=2 BGCOLOR=#EFEFEF>";
// if ($REQUEST_METHOD=="POST") // if page is loaded from a post
if($_POST[’name11’]!=null)
{
print "cam e here";
$name=$_POST[’name11’];
$email=$_POST[’email11’];
$postupdate = "INSERT INTO newsletter (name, email) VALUES (’$name’, ’$email’)";
$postupdateer = mysql_query($postupdate);
print "<FONT SIZE=’3’ color=’#000080’>You have successfully subscribed to the newsletter!</FONT></center>";
}
print "<form method=get ><INPUT TYPE=’hidden’ NAME=’e_email’ VALUE=’- email’>";
print "<table cellspacing=0 cellpadding=2 border=0>";
print "<tr><td align=right><FONT SIZE=2>Name:</FONT></td><td><INPUT TYPE=text NAME=name11 SIZE=30 maxlength=30></td></tr>";
print "<tr><td align=right><FONT SIZE=2>Email:</FONT></td><td><INPUT TYPE=text NAME=email11 SIZE=30 maxlength=30></td></tr>";
print "<tr><td></td><td><INPUT TYPE=’submit’ VALUE=’Subscribe’ ></td></tr>";
print "</table></FORM></TD></TR></TABLE></TD></TR></TABLE>";
?>
So you DON’T want to use
http://modxcms.com/forums/index.php/topic,8111.0.html ?
and have you checked out Easy Newsletters (module) in the extras?
Forum Tip! --> Mark/select the code text and click

button
Example