Results 1 to 15 of 15

Thread: [RESOLVED] POST method wordpress

  1. #1

    Thread Starter
    Addicted Member Pc Monk's Avatar
    Join Date
    Feb 2010
    Posts
    188

    Resolved [RESOLVED] POST method wordpress

    Hi Everyone
    i'm having hard time using the post method for a button in wordpress
    gonna go straight to the code, just one thing since i'm using a plugin the <php> tag converted to [php]
    PHP Code:
    <?php
    if (isset($_POST['downloadbtn'])) {
    echo 
    "IT IS WORKING ";
    die();        
    }
    ?>

    <CONTEXT>

    <form method="post" action="#" >
    [button open_new_tab="true" color="Extra-Color-2" size="small" url="#" text="Download 32Bit" name="downloadbtn" ]
    </form>
    as you see i'm trying to write a code that when the user pressed the button then i echo out something!
    but the form with post method does not work! and i'm running out of idea how to do this post method, i dont want to use the <input type="submit" > cause i loose some gui

    Thanks In Advance
    Last edited by Pc Monk; Feb 21st, 2014 at 08:44 AM.
    Body Language tells the truth! even from the grave tsaeb eht morf gninnur ,nwod deaH
    All the big things started from little! teef my tsap evom sekans ,duol raor slluB
    Lietome.ir

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: POST method wordpress

    I think you'll need ot post the form via javascript... then invoke the js from the onClick event of the button.

    Code:
    [button open_new_tab="true" color="Extra-Color-2" size="small" url="#" text="Download 32Bit" name="downloadbtn" onClick="postForm();" ]
    Then the js would do the form.post operation.

    if I had an example I'd post it... I've done it before, but not through the WP plugin... so I'm still not 100% sure it will work. The trick will be getting the js inserted at the right spot.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Addicted Member Pc Monk's Avatar
    Join Date
    Feb 2010
    Posts
    188

    Re: POST method wordpress

    its been 2 days i'm trying with js and its not working and i'm pissed
    Body Language tells the truth! even from the grave tsaeb eht morf gninnur ,nwod deaH
    All the big things started from little! teef my tsap evom sekans ,duol raor slluB
    Lietome.ir

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: POST method wordpress

    I have seen an interesting issue with trying to submit via javascript. If you try to submit a form with javascript and you have a submit button in the form, it wont work. I dont see a submit button in the code you used, but that might effect if if you do.

  5. #5

    Thread Starter
    Addicted Member Pc Monk's Avatar
    Join Date
    Feb 2010
    Posts
    188

    Re: POST method wordpress

    the problem is that since its in wordpress i have to use
    Code:
    [button open_new_tab="true" color="Extra-Color-2" size="small" url="#" text="Download 32Bit" name="downloadbtn" ]
    as the submit button and even if i put it in the form tag it wont work , using <input> in any kind is forbidden..and i'm running out of time and idea and i would like to kill someone!!
    any help would be much appreciate
    Body Language tells the truth! even from the grave tsaeb eht morf gninnur ,nwod deaH
    All the big things started from little! teef my tsap evom sekans ,duol raor slluB
    Lietome.ir

  6. #6
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: POST method wordpress

    I am not too familiar with word press. Try looking at the source code on the published page and post the code from that. See what it is actually displaying.

  7. #7
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: POST method wordpress

    Or post in the WP forums...

    However, if you are using the plugin that I think you'tre using... this isn't quite what it was intended for.
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    Addicted Member Pc Monk's Avatar
    Join Date
    Feb 2010
    Posts
    188

    Re: POST method wordpress

    i found a way and i'm working on it , i'll share more info when i'm done with it
    Body Language tells the truth! even from the grave tsaeb eht morf gninnur ,nwod deaH
    All the big things started from little! teef my tsap evom sekans ,duol raor slluB
    Lietome.ir

  9. #9
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: POST method wordpress

    Quote Originally Posted by techgnome View Post
    Or post in the WP forums...

    However, if you are using the plugin that I think you'tre using... this isn't quite what it was intended for.
    -tg
    I'm curious what you are thinking... Can't PM you to ask either... Hmmm

  10. #10

    Thread Starter
    Addicted Member Pc Monk's Avatar
    Join Date
    Feb 2010
    Posts
    188

    Re: POST method wordpress

    this 1 is so redicioules here we go
    PHP Code:
    <?php

    $username 
    "u440";
    $password "1234";
    $hostname "localhost";

    //connection to the database
    $dbhandle mysql_connect($hostname,$password,$username)
    or 
    mysqli_error();
    echo 
    "Connected to MySQL<br>";


    if(isset(
    $_GET['type'])) {
        
        
    $type $_GET['type'];

    $query ="SELECT `avg32 from `antivirus` where 1";
    if(
    $query_run mysql_query($query)) {
        
    echo 
    'ok';    
    }
    else{
        echo 
    'no';
        echo 
    mysql_error();
    }


       switch(
    $type) {
           
       
       case 
    "avg32" :
           
           
    $query="update `antivirus` SET `avg32`=`avg32` +1";
                   
    $query_run mysqli_query($query);
                   
           
       case 
    "avg64" :
           
           
    $query="update `antivirus` SET `avg64`=`avg64` +1";
                   
    $query_run mysqli_query($query);
           
       case 
    "nod32" :
           
           
    $query="update `antivirus` SET `nod32`=`nod32` +1";
                   
    $query_run mysqli_query($query);
           
       case 
    "nod64" :
           
           
    $query="update `antivirus` SET `nod64`=`nod64` +1";
                   
    $query_run mysqli_query($query);
           
       case 
    "norton32" :
           
           
    $query="update `antivirus` SET `norton32`=`norton32` +1";
                   
    $query_run mysqli_query($query);
           
       case 
    "norton64" :

           
    $query="update `antivirus` SET `norton64`=`norton64` +1";
                   
    $query_run mysqli_query($query);
           
       case 
    "kaspersky32" :

           
    $query="update `antivirus` SET `kaspersky32`=`kaspersky32` +1";
                   
    $query_run mysqli_query($query);
           
       case 
    "kaspersky64" :

           
    $query="update `antivirus` SET `kaspersky64`=`kaspersky64` +1";
                   
    $query_run mysqli_query($query);
           
       case 
    "avira32" :
           
           
    $query="update `antivirus` SET `avira32`=`avira32` +1";
                   
    $query_run mysqli_query($query);
           
       case 
    "avira64" :

           
    $query="update `antivirus` SET `avira64`=`avira64` +1";
                   
    $query_run mysqli_query($query);
           
       case 
    "avast32" :

           
    $query="update `antivirus` SET `avast32`=`avast32` +1";
                   
    $query_run mysqli_query($query);
           
              case 
    "avast64" :

                  
    $query="update `antivirus` SET `avast64`=`avast64` +1";
                          
    $query_run mysqli_query($query);
                  
       }


        }

           
    ?>
    [
    now what i get is :
    Connected to MySQL
    no Access denied for user 'root'@'localhost' (using password: NO)
    ......
    now how funny this can be ?
    any idea ?
    Body Language tells the truth! even from the grave tsaeb eht morf gninnur ,nwod deaH
    All the big things started from little! teef my tsap evom sekans ,duol raor slluB
    Lietome.ir

  11. #11
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: POST method wordpress

    Quote Originally Posted by Pc Monk View Post
    this 1 is so redicioules here we go
    now what i get is :
    Connected to MySQL
    no Access denied for user 'root'@'localhost' (using password: NO)
    ......
    now how funny this can be ?
    any idea ?
    You are mixing up mysql functions with mysqli functions... And also your mysql_connect parameters are backwards, should be mysql_connect(host, username, password).

    You connect with mysql_ and then you are printing errors from the mysqli_ function.

    Your if statement is also always going to return true...
    PHP Code:
    if($query_run mysql_query($query)) { 
    You are setting $query_run to be equal to mysql_query($query), so it will always return true. You need to use conditional operators there: ==, !=, <, >, <=, >=, etc.

    Start with that, see if changing those errors fix anything.

  12. #12
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: POST method wordpress

    Quote Originally Posted by dclamp View Post
    I'm curious what you are thinking... Can't PM you to ask either... Hmmm
    There's a fairly popular WP Plugin that allows you to "write PHP" code into a post and it will run. Like I said, it's a fairly popular and commonly used plugin. I've used it quite a bit too. But it's original intent was to allow for processing and display. I'm sure you can use it to create forms and post with it... but to do it the way the OP wants to, you would need to include some js to post the form when the element is clicked. That's the part I'm not sure you can do with this particular plugin.

    as for the database... WP uses the mysqli ... it's amazing the difference a single little letter can make.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  13. #13

    Thread Starter
    Addicted Member Pc Monk's Avatar
    Join Date
    Feb 2010
    Posts
    188

    Re: POST method wordpress

    i was thinking about the host but when i changed the mysql_connect(host, username, password). it did work ! i did change the host , anyway i continue and i'll post the result

    Quote Originally Posted by techgnome View Post
    There's a fairly popular WP Plugin that allows you to "write PHP" code into a post and it will run. Like I said, it's a fairly popular and commonly used plugin. I've used it quite a bit too. But it's original intent was to allow for processing and display. I'm sure you can use it to create forms and post with it... but to do it the way the OP wants to, you would need to include some js to post the form when the element is clicked. That's the part I'm not sure you can do with this particular plugin.

    as for the database... WP uses the mysqli ... it's amazing the difference a single little letter can make.

    -tg
    the wp wont work with js autosubmit..it wont execute the commend under my button since i'm not using the <input> ..hope i can finish this today since i'm running out of time
    Body Language tells the truth! even from the grave tsaeb eht morf gninnur ,nwod deaH
    All the big things started from little! teef my tsap evom sekans ,duol raor slluB
    Lietome.ir

  14. #14

    Thread Starter
    Addicted Member Pc Monk's Avatar
    Join Date
    Feb 2010
    Posts
    188

    Re: POST method wordpress

    3 way to explain this :
    1- my mind does not functioning well ( i doubt that)
    2- long time i didnt code so i might forget some things ( i dont think so )
    3- what ever it is , its making me angry
    and all these funny problems that i'm facing making me laugh
    anyway heres the code
    PHP Code:
    include ('dbin.php');
    if(isset(
    $_GET['type'])) {
        
        
    $type $_GET['type'];

    $query ="SELECT `avg32`,`avg64` from `antivirus` ";
    if(
    $query_run mysql_query($query)) {
        while(
    $query_result mysql_fetch_assoc($query_run)) { 
        
        
    $avg32 $query_result['avg32'];
        
    $avg64 $query_result['avg64'];
        echo 
    $avg32.'echo out';
        
        
        }
        
        
    }
    else{
        echo 
    'no';
        echo 
    mysql_error();

    the rest of this its the switch part...after we receive the type it will see if we have any record and it will echo it out and then the switch part will increase it ! and here is the funny part i dont get any thing echo out from the while {} not even the string part 'echo out' .i should mention anything out of the WHILE will be echo out
    thanks for any help !
    Body Language tells the truth! even from the grave tsaeb eht morf gninnur ,nwod deaH
    All the big things started from little! teef my tsap evom sekans ,duol raor slluB
    Lietome.ir

  15. #15

    Thread Starter
    Addicted Member Pc Monk's Avatar
    Join Date
    Feb 2010
    Posts
    188

    Re: POST method wordpress

    i dont know how many of u guys played world of warcraft ... there is an achivement in there called "Working day and night" guess i just earned it..the last problem i had was so funny i removed the " ` " and it got fixed. in this peice of code
    Code:
     [button open_new_tab="true" color="Extra-Color-2" size="small" url="#" text="Download 32Bit" name="downloadbtn" ]
    i couldnt use js it wouldn't work , php wouldn't work either so i decided in the url to redirect it to a php page that would do all the work and then redirect the user to the download page!
    Thanks to whoever helped me
    GoodDuck
    Body Language tells the truth! even from the grave tsaeb eht morf gninnur ,nwod deaH
    All the big things started from little! teef my tsap evom sekans ,duol raor slluB
    Lietome.ir

Posting Permissions

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



Click Here to Expand Forum to Full Width