Note that there are some explanatory texts on larger screens.

plurals
  1. POunsubscribe html form using php and my sql
    text
    copied!<p>I have an html form where people can subscribe to a mailing list. The form includes form validation and when the form is submitted, the data is stored in a database using My SQL. </p> <p>Here is the code on the index.html page where the form is</p> <pre><code> &lt;form id="subscribe-form" action="send.php" method="post"&gt; &lt;p id="status"&gt;&lt;/p&gt; &lt;div&gt; &lt;label for="title"&gt;Title:&lt;/label&gt; &lt;select class="uniform" name="title" id="title"&gt; &lt;option&gt;Please Choose&lt;/option&gt; &lt;option&gt;Mr&lt;/option&gt; &lt;option&gt;Mrs&lt;/option&gt; &lt;option&gt;Miss&lt;/option&gt; &lt;option&gt;Ms&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div&gt; &lt;label for="firstName"&gt;First name:&lt;/label&gt; &lt;input type="text" id="firstName" name="firstName" /&gt; &lt;/div&gt; &lt;div&gt; &lt;label for="surname"&gt;Surname:&lt;/label&gt; &lt;input type="text" id="surname" name="surname" /&gt; &lt;/div&gt; &lt;div&gt; &lt;label for="email"&gt;Email:&lt;/label&gt; &lt;input type="text" id="email" name="email" /&gt; &lt;/div&gt; &lt;div&gt; &lt;label for="phone"&gt;Contact Number:&lt;/label&gt; &lt;input type="text" id="phone" name="phone" /&gt; &lt;/div&gt; &lt;div&gt; &lt;label for="title"&gt;How did you hear about us?&lt;/label&gt; &lt;select class="uniform" name="refer" id="refer"&gt; &lt;option&gt;Please Choose&lt;/option&gt; &lt;option&gt;Google&lt;/option&gt; &lt;option&gt;Yahoo&lt;/option&gt; &lt;option&gt;Word of Mouth&lt;/option&gt; &lt;option&gt;Others&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div&gt; &lt;input type="checkbox" name="news_updates" value="1" /&gt; I'd like to hear about the latest news and events updates&lt;/div&gt; &lt;div&gt; &lt;input class="button" type="submit" value=""/&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>Here is the code for send.php</p> <pre><code>&lt;?php include ('connection.php'); $sql="INSERT INTO form_data (title,firstName, surname, email, phone, refer, news_updates) VALUES ('$_POST[title]', '$_POST[firstName]','$_POST[surname]','$_POST[email]','$_POST[phone]','$_POST[refer]','$_POST[news_updates]')"; if (!mysql_query($sql, $connected)) { die('Error: ' . mysql_error()); } mysql_close($connected); ?&gt; </code></pre> <p>I would like to make another html (unsubscribe.html) page where people can unsubscribe by entering their email address so that their email address would match the corresponding email that is in the database already and remove it from the My Sql database . I found this tutorial which was kind of helpful - <a href="http://www.phpsuperblog.com/php/delete-records-from-mysql-database-with-html-form-and-php/" rel="nofollow">http://www.phpsuperblog.com/php/delete-records-from-mysql-database-with-html-form-and-php/</a></p> <p>and this is the form on my unsubscribe.html page. </p> <pre><code> &lt;form id="unsubscribe_form" action="delete.php" method="post"&gt; &lt;div&gt; &lt;label for="email_remove"&gt;Email:&lt;/label&gt; &lt;input type="text" id="email_remove" name="email_remove" /&gt; &lt;/div&gt; &lt;div&gt; &lt;input name="delete" type="submit" id="delete" value="" class="unsubscribe_btn"&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>but when I enter method="post" in the unsubscribe form. The data from the form on the subscribe / index.html does not get stored in My Sql, instead they come up as blank. So I am guessing I can't have two "post" method maybe?? </p> <p>If someone could guide me in the right direction that would be much appreciate. Thanks. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload