Need help with a php form!

Kelsen

Regular Member
Joined
Feb 15, 2011
Messages
289
Reaction score
66
I could use some help with an Email subscribe tool.


This is what the Guide says


Code:
      Install Optin ? Still on the Appearance > Editor page, click the ?optin.php?
link. Replace the form elements in that file with those from your web  form and add any additional inputs that your web form may have.
and this is the optin.php code
Code:
     <div class="fatlossoptin">
  <div class="fatlossoptincontent">
  <!-- Customize the form below so it works with your email service  provider. Make sure you keep the classes for the inputs and submit  button -->
    <form method='POST' name='NAMEHERE' action='Weight-loss-Ebook'>

      <table width="240" border="0" cellspacing="0" cellpadding="5" align="center">
        <tr>
          <td width="71">Name:</td>
          <td width="169">
              <input type="text" name="textfield" id="NAMEIDHERE" class="text" />
            </td>
        </tr>
        <tr>
          <td>Email:</td>
          <td><input type="text" name="textfield2" id="EMAILIDHERE" class="text" /></td>
        </tr>
        <tr>
          <td colspan="2" align="center"><input type="submit" class="button" value=""/></td>
        </tr>
      </table>
    </form>
  </div>
</div>
 
What it means by replace the form elements is change the form id's/names to the ones you are using on your page for the form, it's quite simple. PM me if you still don't figure it out.
 
So what's your question?
I Lolled!
The question is: What should I do?! I'm a noob in this kind of stuff.
What it means by replace the form elements is change the form id's/names to the ones you are using on your page for the form, it's quite simple. PM me if you still don't figure it out.
Thanks! I will try to figure it out tomorrow, i can't I shall pm you!
 
Just guessing your intention.

What you need to replace:
-. name='NAMEHERE' action='Weight-loss-Ebook'
replace this with: name="myoptinform" action="opintaction.php"

-. name="textfield" id="NAMEIDHERE" class="text"
replace this with: name="fullname" id="fullname"

-. name="textfield2" id="EMAILHERE" class="text"
replace this with: name="emailaddress" id="emailaddress"

Now, you need 1 more file to create: opintaction.php
This file will handle a post of your form once it gets submitted, for example:

PHP:
<?php
$fullname = isset($_POST["fullname"]) ? $_POST["fullname"] : "";
$email = isset($_POST["emailaddress"]) ? $_POST["emailaddress"] : "";

// make sure you have table ready on your database
// f.i. table name is myoptin and it has fullname and emailaddress columns
mysql_query("INSERT INTO myoptin (fullname,emailaddress) VALUES ('".mysql_real_escape($fullname).'", '".mysql_real_escape($email)."')"
?>
 
Back
Top