简体   繁体   中英

Unable to get JFactory::getApplication in joomla using cBox popup

I am Developing popup component for joomla site, The Pop up Working Great , In my Popup i get phone number from user, i need to store that phone number to joomla database , but i am unable to call JFactory::getDBo(), when i call these method , popup was not working, i am in trouble , any help will be appreciate me.. thanxs in advance...

site/default.php

 <script>
  function openColorBox() {
    $.colorbox({
      innerWidth:500, 
      innerHeight:300, 
      iframe:true,
      href: "subscribe.php",
      overlayClose:true,
      onLoad: function() {
        $('#cboxClose').remove();
      }
    });
  }
  setTimeout(openColorBox, 1000);
</script>

site/subscribe.php

 <body class="oneColFixCtr">
<div id="container">

  <form name="Mail_list" action="#" method="post">

    <p>
      <label for="phone">Your Mobile Number </label>
      <input type="tel" name="phone" id="phone" size="10"  pattern="\d{10}" required />
      <input type="hidden" name="date1" id="date1" value="<?php echo date('d.m.y'); ?>" />
    </p>
    <input type="submit" name="submit" value="Enter">
  </form> 
</div>

Your form is not posting the data anywhere when sumitted. Your action="#" will never allow the form to submit. Set your action to PHP_SELF if you need to submit it back to subscribe.php, then have a check in your subscribe.php that processes your form.

The better method would be to have your popup content in a hidden div and open that div instead of using an iframe. Use subscribe.php as your logic for saving the users data to the database. Using ajax to submit the form wouldn't be a bad idea either.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM