Announcement

Collapse
No announcement yet.

PHP Direct code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mike4x4
    replied
    all working now, just 1 question is there a variable i can output in the cms the username im logged in as on vbulletin?

    Leave a comment:


  • Removed-836727
    replied
    |=>
    What's your php code?
    Do you check if it's a ajax request and do you send a special content back?

    Leave a comment:


  • Mike4x4
    replied
    sorry very tight on money at this time i will have to keep trying till i get it

    Leave a comment:


  • Removed-836727
    replied
    It seems that you're sending your request to ("GET", "content.php?125" + queryString, true); and your getting your complete page back...

    What's your php code?
    Do you check if it's a ajax request and do you send a special content back?


    If you want, create me an admin account, describe what you exactly want!
    If i can code it, you pay 60$ per paypal(special christmas price), if not, you have to pay me nothing

    Leave a comment:


  • Mike4x4
    replied
    that works great!! Just 1 more error im encountering when i click the form submit "update" it seems to reload the whole page below, please look at my attachment.
    Attached Files

    Leave a comment:


  • Removed-836727
    replied
    PHP Code:
    $output .= <<<JS
    <script language="javascript" type="text/javascript">
    <!--
    //Browser Support Code
    function ajaxFunction(){
    var ajaxRequest; // The variable that makes Ajax possible!

    try{
    // Opera 8.0+, Firefox, Safari
    ajaxRequest = new XMLHttpRequest();
    } catch (e){
    // Internet Explorer Browsers
    try{
    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try{
    ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e){
    // Something went wrong
    alert("Your browser broke!");
    return false;
    }
    }
    }
    // Create a function that will receive data sent from the server
    ajaxRequest.onreadystatechange = function(){
    if(ajaxRequest.readyState == 4){
    var ajaxDisplay = document.getElementById('ajaxDiv');
    ajaxDisplay.innerHTML = ajaxRequest.responseText;
    }
    }
    var username = document.getElementById('username').value;
    var userlevel = document.getElementById('userlevel').value;
    var queryString = "?username=" + username + "&userlevel=" + userlevel;
    ajaxRequest.open("GET", "content.php?125" + queryString, true);
    ajaxRequest.send(null);
    }
    //-->
    </script>
    JS; 
    would be IMHO nicer, but as i said already, create a template:P

    Leave a comment:


  • Mike4x4
    replied
    So you mean the code will look like this??, if so its still producing the error"

    Code:
    $output .='<script language="javascript" type="text/javascript">';
    $output .=' <!--'; 
    $output .='//Browser Support Code';
     $output .='function ajaxFunction(){';
     $output .='var ajaxRequest; // The variable that makes Ajax possible!';
    $output .=' try{';';
     $output .='// Opera 8.0+, Firefox, Safari';
    $output .=' ajaxRequest = new XMLHttpRequest();';
    $output .=' } catch (e){';
     $output .='// Internet Explorer Browsers';
    $output .=' try{';
     $output .='ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");';
    $output .=' } catch (e) {';
    $output .=' try{';
    $output .=' ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");';
    $output .=' } catch (e){';
    $output .=' // Something went wrong';
    $output .=' alert("Your browser broke!");';
     $output .='return false;';
    $output .=' }';
     $output .='}';
    $output .=' }';
    $output .=' // Create a function that will receive data sent from the server';
    $output .=' ajaxRequest.onreadystatechange = function(){';
    $output .=' if(ajaxRequest.readyState == 4){';
    $output .=' var ajaxDisplay = document.getElementById('ajaxDiv');';
     $output .='ajaxDisplay.innerHTML = ajaxRequest.responseText;';
    $output .=' }';
    $output .=' }';
    $output .=' var username = document.getElementById('username').value;';
    $output .=' var userlevel = document.getElementById('userlevel').value;';
    $output .=' var queryString = "?username=" + username + "&userlevel=" + userlevel;';
    $output .=' ajaxRequest.open("GET", "content.php?125" + queryString, true);';
    $output .=' ajaxRequest.send(null);'; 
    $output .='}';
    $output .=' //-->';
    $output .=' </script>';
    Originally posted by ragtek View Post
    ugly˛

    instead of escaping all the " you could use '
    $output .='<script language="javascript" type="text/javascript">etc

    Leave a comment:


  • Removed-836727
    replied
    $output .="<script language=\"javascript\" type=\"text/javascript\">
    ugly˛

    instead of escaping all the " you could use '
    $output .='<script language="javascript" type="text/javascript">etc

    Leave a comment:


  • Lynne
    replied
    As already said, it would be better to just create your own template and put the javascript directly into there. If you are going to do it the way you are, you need to escape all the double-quotes:
    PHP Code:
    $output .="<script language=\"javascript\" type=\"text/javascript\">
    etc 
    Also, please read the Forum Rules regarding bumping of posts. You should not bump them in less than 24 hours.

    Leave a comment:


  • Mike4x4
    replied
    bump

    Leave a comment:


  • Mike4x4
    replied
    i will just use my code im not very good,

    so to intergrate it with the output variable it would be:???

    Code:
    $output .="<script language="javascript" type="text/javascript">
    <!-- 
    //Browser Support Code
    function ajaxFunction(){
    var ajaxRequest; // The variable that makes Ajax possible!
     
    try{
    // Opera 8.0+, Firefox, Safari
    ajaxRequest = new XMLHttpRequest();
    } catch (e){
    // Internet Explorer Browsers
    try{
    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try{
    ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e){
    // Something went wrong
    alert("Your browser broke!");
    return false;
    }
    }
    }
    // Create a function that will receive data sent from the server
    ajaxRequest.onreadystatechange = function(){
    if(ajaxRequest.readyState == 4){
    var ajaxDisplay = document.getElementById('ajaxDiv');
    ajaxDisplay.innerHTML = ajaxRequest.responseText;
    }
    }
    var username = document.getElementById('username').value;
    var userlevel = document.getElementById('userlevel').value;
    var queryString = "?username=" + username + "&userlevel=" + userlevel;
    ajaxRequest.open("GET", "content.php?125" + queryString, true);
    ajaxRequest.send(null); 
    }
    //-->
    </script>";

    Leave a comment:


  • hababam
    replied
    this is great

    Leave a comment:


  • Removed-836727
    replied
    also put it into the output variable!

    But IMHO it would be better, to create a own template for this!

    Also you don't need a own ajax call! Use the yui connection which is already available in vB global

    Leave a comment:


  • Mike4x4
    replied
    sorry all working now, but running into same problem when adding javascript to top of the page, what is the best way to overcome the error:

    <script language="javascript" type="text/javascript">
    <!--
    //Browser Support Code
    function ajaxFunction(){
    var ajaxRequest; // The variable that makes Ajax possible!

    try{
    // Opera 8.0+, Firefox, Safari
    ajaxRequest = new XMLHttpRequest();
    } catch (e){
    // Internet Explorer Browsers
    try{
    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try{
    ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e){
    // Something went wrong
    alert("Your browser broke!");
    return false;
    }
    }
    }
    // Create a function that will receive data sent from the server
    ajaxRequest.onreadystatechange = function(){
    if(ajaxRequest.readyState == 4){
    var ajaxDisplay = document.getElementById('ajaxDiv');
    ajaxDisplay.innerHTML = ajaxRequest.responseText;
    }
    }
    var username = document.getElementById('username').value;
    var userlevel = document.getElementById('userlevel').value;
    var queryString = "?username=" + username + "&userlevel=" + userlevel;
    ajaxRequest.open("GET", "content.php?125" + queryString, true);
    ajaxRequest.send(null);
    }
    //-->
    </script>

    Leave a comment:


  • Removed-836727
    replied
    where do you insert it?

    You have to put <strong>administrator</strong> also into the $output variable because it's html and not php

    Leave a comment:

Related Topics

Collapse

Working...
X