SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Data Won't Inset

    I bought this script to mess around with and the data won't insert from the control panel in the settings tab. No one else has reported this issue and the developer pretty much gives 0 support so I figured somewhere here may know.


    This is the entire settings.php file.


    PHP Code:
    <?
    if(! defined('BASEPATH') ){ exit('Unable to view file.'); }

    $site $db->FetchArray($db->Query("SELECT * FROM `settings` LIMIT 1"));

    if(isset(
    $_POST['submit'])){
        
    $db->Query("UPDATE `settings` SET `site_name`='{$_POST['name']}', `site_description`='{$_POST['description']}', `site_url`='{$_POST['url']}', `paypal`='{$_POST['paypal']}', `site_email`='{$_POST['email']}', `maintenance`='{$_POST['mode']}', `m_progress`='{$_POST['progress']}'");
        
    $mesaj "<div class=\"message success\"><h3>Success!</h3><p>Settings successfully changed</p></div>";
    }
    if(isset(
    $_POST['usubmit'])){
        
    $db->Query("UPDATE `settings` SET `surf_time`='{$_POST['surf_time']}', `ref_coins`='{$_POST['ref_coins']}', `reg_coins`='{$_POST['reg_coins']}', `reg_status`='{$_POST['reg_status']}', `reg_logtype`='{$_POST['reg_logtype']}', `reg_reqmail`='{$_POST['reg_reqmail']}'");
        
    $mesaj "<div class=\"message success\"><h3>Success!</h3><p>Settings successfully changed</p></div>";
    }
    ?>
                <div id="page-subheader">
                    <div class="wrapper clearfix">
                        <nav id="sub-nav"></nav>
                    </div>
                </div>
    <script> 
    $(document).ready(function(){
        // Regular Expression to test whether the value is valid
        $.tools.validator.fn("[type=time]", "Please supply a valid time", function(input, value) { 
            return /^\d\d:\d\d$/.test(value);
        });
         
        $.tools.validator.fn("[data-equals]", "Value not equal with the $1 field", function(input) {
            var name = input.attr("data-equals"),
                 field = this.getInputs().filter("[name=" + name + "]"); 
            return input.val() == field.val() ? true : [name]; 
        });
         
        $.tools.validator.fn("[minlength]", function(input, value) {
            var min = input.attr("minlength");
            
            return value.length >= min ? true : {     
                en: "Please provide at least " +min+ " character" + (min > 1 ? "s" : "")
            };
        });
         
        $.tools.validator.localizeFn("[type=time]", {
            en: 'Please supply a valid time'
        });
         
        $("#form").validator({ 
            position: 'left', 
            offset: [25, 10],
            messageClass:'form-error',
            message: '<div><em/></div>' // em element is the arrow
        }).attr('novalidate', 'novalidate');

    });
    </script>
    </header>
            
            <section id="content">
                <div class="wrapper">
                    <section class="top"><? echo $mesaj;?>
                            <div class="grid_4 columns first">
                                <form id="form" method="post" class="form widget">
                                    <header><h2>General Settings</h2></header>
                                    <section>                 
                                        <fieldset>
                                             <dl>
                                                 <dt></dt><dd><label>Site Title</label><input type="text" name="name" value="<?=(isset($_POST['name']) ? $_POST['name'] : $site['site_name'])?>" required="required" /></dd>
                                                 <dt></dt><dd><label>Site Description</label><input type="text" name="description" value="<?=(isset($_POST['description']) ? $_POST['description'] : $site['site_description'])?>" required="required" /></dd>
                                                 <dt></dt><dd><label>Site URL</label><input type="text" name="url" value="<?=(isset($_POST['url']) ? $_POST['url'] : $site['site_url'])?>" required="required" /></dd>
                                                 <dt></dt><dd><label>Contact Email</label><input type="email" name="email" value="<?=(isset($_POST['email']) ? $_POST['email'] : $site['site_email'])?>" required="required" /></dd>
                                                 <dt></dt><dd><label>Paypal Email</label><input type="email" name="paypal" value="<?=(isset($_POST['paypal']) ? $_POST['paypal'] : $site['paypal'])?>" required="required" /></dd>
                                                 <dt><label>Maintenance Mode</label></dt><dd></dd>
                                                 <dt></dt><dd><label>Status</label><select name="mode"><option value="0">Inactive</option><option value="1"<?=($site['maintenance'] != ' selected' '')?>>Active</option></select></dd>
                                                 <dt></dt><dd><label>Progress %</label><input type="text" name="progress" value="<?=$site['m_progress']?>" required="required" /></dd>
                                             </dl>    
                                         </fieldset>
                                         <hr />
                                         <button class="button button-green" type="submit" name="submit">Submit</button>
                                         <button class="button button-gray" type="reset">Reset</button>
                                    </section>
                                </form>
                            </div>

                        <div class="grid_4 columns">
                                <form id="form" method="post" class="form widget">
                                    <header><h2>User Settings</h2></header>
                                    <section>                 
                                        <fieldset>
                                             <dl>
                                                 <dt></dt><dd><label>Coins per Referral</label><input type="text" name="ref_coins" value="<?=(isset($_POST['ref_coins']) ? $_POST['ref_coins'] : $site['ref_coins'])?>" required="required" /></dd>
                                                 <dt></dt><dd><label>Coins on Signup</label><input type="text" name="reg_coins" value="<?=(isset($_POST['reg_coins']) ? $_POST['reg_coins'] : $site['reg_coins'])?>" required="required" /></dd>
                                                 <dt></dt><dd><label>Auto-surf time (seconds)</label><input type="text" name="surf_time" value="<?=(isset($_POST['surf_time']) ? $_POST['surf_time'] : $site['surf_time'])?>" required="required" /></dd>
                                                 <dt></dt><dd><label>Login with</label><select name="reg_logtype"><option value="0">Username</option><option value="1"<?=($site['reg_logtype'] != ' selected' '')?>>Email</option></select></dd>
                                                 <dt></dt><dd><label>Email Confirmation</label><select name="reg_reqmail"><option value="0">Enabled</option><option value="1"<?=($site['reg_reqmail'] != ' selected' '')?>>Disabled</option></select></dd>
                                                 <dt></dt><dd><label>Registration</label><select name="reg_status"><option value="0">Enabled</option><option value="1"<?=($site['reg_status'] != ' selected' '')?>>Disabled</option></select></dd>
                                             </dl>    
                                         </fieldset>
                                         <hr />
                                         <button class="button button-green" type="submit" name="usubmit">Submit</button>
                                         <button class="button button-gray" type="reset">Reset</button>
                                    </section>
                                </form>
                        </div>
                    </section>
                    <div class="clear"></div>
                </div>
                <div id="push"></div>
            </section>

        </div>
        
        <footer id="page-footer">
            <div id="footer-inner">
                <p class="wrapper">All rights reserved &copy; <a href="http://mafianet.org" target="_blank">MafiaNet</a> <?=date('Y')?></p>
            </div>
        </footer>
    </body>
    </html>

    If anyone has any idea why that isn't working I'd love to know. It comes up that it saves successfully but upon refreshing all the settings are back to blank.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    did you test your queries outside of php first?

    if the queries work okay with hardcoded values, then your problem is a php issue
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict kduv's Avatar
    Join Date
    May 2012
    Location
    Maui, HI
    Posts
    211
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Are you getting any error messages?

  4. #4
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    The $_POST values in your code should be escaped to stop 'bad scoobies' from breaking your database. This can be done by putting mysql_real_escape_string() around each $_POST value like:
    PHP Code:
    `site_url`='{mysql_real_escape_string($_POST['url'])}' 
    Just before the line that reads
    if(isset($_POST['submit'])){
    you can put a
    PHP Code:
    var_dump($_POST); 
    This will output the entire $_POST array and any values it has. If you issue this and don't see anything but an empty array() then Your Posting process is not working. If you are seeing values then you need to did deeper into the SQL and as has already been suggested run the SQL lines that you see replacing the $_POST with real string values.

    Steve



    ictus==""


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •