We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11703
    • 1 Posts
    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>";
    ?>
      • 20413
      • 2,877 Posts
      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
      <form...
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 36592
        • 970 Posts
        I’m not a PHP programmer so I’m not sure but ...
        print "<form method=get >...

        This might be something like this ... ?
        print "<form method='post' >...