Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Dec 2008
    Posts
    133
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Exclamation submit button issue

    PHP Code:
                if ($username != 'mic4'){
                    if (
    $info->lastcrime time()){
                        
    $timeleft $info->lastcrime time();
                            echo 
    "<font color=\"white\"><center><br /><br /><strong>"
                                
    ."$timeleft seconds before you can do another cime!</strong><br /><br /></center>";
                                
                                
                                if(
    $session->isAdmin()){ //New bit
                                    
    echo '<center><input name="resetadmin" id="resetadmin" type="submit" value="reset admin" /></center>';                                              } 
                                    
    //Function to show link to admin centre
                               
                            
    exit(); }
                    } 

    Thats the submit button (its in the $session->admin if statement), when clicked i want it to execute this code only:

    PHP Code:
    //New bit
                    
    if (strip_tags($_POST['resetadmin'])){
                                    
                        
    $reset_admin strip_tags($_POST['resetadmin']);
                        
    mysql_query("UPDATE users SET lastcrime='0', WHERE username='$username'");
                    };
    //end new bit 

    I can't get it to execute the above code, a solution would be apreciated
    I'm sure its me having a mental block :P

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,285
    Thanks
    4
    Thanked 201 Times in 198 Posts
    Where is the form statement and what code is it calling?
    Dave .... HostMonster for all of your hosting needs

  • #3
    Regular Coder
    Join Date
    Dec 2008
    Posts
    133
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by djm0219 View Post
    Where is the form statement and what code is it calling?
    I have to put the button in a form?

    Damn i want to now create a new form statement and create a function to execute the bottom codebox code.

  • #4
    bdl
    bdl is offline
    Regular Coder
    Join Date
    Apr 2007
    Location
    Camarillo, CA US
    Posts
    590
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Quote Originally Posted by CallumJohnson View Post
    I have to put the button in a form?

    Damn i want to now create a new form statement and create a function to execute the bottom codebox code.
    I know this wasn't meant to be funny, but I had a chuckle at your expense, I think.

    You technically don't have to wrap an INPUT or BUTTON in a FORM element, but it's not usable unless you use JavaScript / DOM code to make it work. Doing so would require everyone that uses your application to have JavaScript enabled or use a certain browser to ensure compatibility, and that's not likely.

  • #5
    Regular Coder
    Join Date
    Dec 2008
    Posts
    133
    Thanks
    15
    Thanked 0 Times in 0 Posts
    ahhhh, how does one direct a form's action"" tag to a specific function?

  • #6
    Regular Coder
    Join Date
    Dec 2008
    Posts
    133
    Thanks
    15
    Thanked 0 Times in 0 Posts
    just like what do i put in the action's "" to make it execute a function?

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by CallumJohnson View Post
    just like what do i put in the action's "" to make it execute a function?
    You can use onclick or onsubmit. This isn't a PHP question though, PHP cannot be executed at runtime on the browser. If you want to perform these actions you need to look into using AJAX.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #8
    Regular Coder
    Join Date
    Dec 2008
    Posts
    133
    Thanks
    15
    Thanked 0 Times in 0 Posts
    I manged to find a workaround:

    PHP Code:
    if($session->isAdmin()){ //Shows link to reset timer if user == admin
                                    
    echo '<center><form action="" method="post"><input name="reset" '
                                    
    .'id="reset" type="submit" value="submit" /></form></center>'; } 
                                    
                                        if (
    $_POST['reset']){ //Grabs if the submit button has been pressed and executes this code
                                             
    $username $session->username;
                                            
    mysql_query("UPDATE users SET lastcrime='0' WHERE username='$username'");
                                            }; 


  •  

    Posting Permissions

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