I am trying to submit a bootstrap popover form with php, however it is not populating the table. any suggestions?
javascript:
<script type="text/javascript">
$(document).ready(function() {
$("[rel='android']").popover({
html: 'true',
content : '<div id="popOver-input"><p id="coming-soon">Coming March 2014</p><p>Be the first to know when buddyTruk goes live!</p><form class="form-horizontal" action="temp.php" method="post"><input type="text" class="form-control input-lg" name="emailFuture" placeholder="Email"/><button class="btn btn-success btn-lg" name="comingSoon" type="submit" value="comingSoon">Submit</button></form></div>'
});
});
php:
<?php
if (isset($_POST['comingSoon']) && strlen($_POST['email'])>0)
{
$coming_soon=$_POST['emailFuture'];
mysql_connect("*****", "****", "*****") or die(mysql_error());
mysql_select_db("buddyTruk") or die(mysql_error());
mysql_query("ALTER TABLE coming_soon ADD PRIMARY KEY (email)");
mysql_query("REPLACE INTO `coming_soon` VALUES ('$coming_soon')");
}
?>
Because there is no input with name email
but you trying : $_POST['email']
, So, change the name:
<script type="text/javascript">
$(document).ready(function() {
$("[rel='android']").popover({
html: 'true',
content : '<div id="popOver-input"><p id="coming-soon">Coming March 2014</p><p>Be the first to know when buddyTruk goes live!</p><form class="form-horizontal" action="temp.php" method="post"><input type="text" class="form-control input-lg" name="email" placeholder="Email"/><button class="btn btn-success btn-lg" name="comingSoon" type="submit" value="comingSoon">Submit</button></form></div>'
});
});
The name
of your email input in the form is emailFuture
. So modify the conditional:
if (isset($_POST['comingSoon']) && strlen($_POST['emailFuture'])>0)
{
// insert
}
I recommend checking that $_POST['emailFuture']
is set also, just in case something goes wrong you don't raise an unnecessary exception. A good substitute for isset() && strlen() > 0
is empty()
, so: (isset($_POST['comingSoon']) && !empty($_POST['emailFuture']))