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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: Link help

  1. #1
    New Coder
    Join Date
    Feb 2008
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Link help

    PHP Code:
    <?php 
    $nickname 
    '';
    $status '';
    $pass '';
    $login '';
    ?>
    <body onLoad="document.all.AnonymousNo.style.visibility='hidden'"> 
    <table width="100%" height="100%">
    <tr>
    <td align="center" width="90%" bgcolor="FFFFFF" border="2" bordercolor="000000">

    <form name="f1" method="post" action="<?php echo  'teamspeak://ts3.gameservers.com:8786?nickname=' $nickname '?loginname=' $login '?password=' $pass ?>">

    <b>Nickname</b><br />
    <input type="text" size="25" maxlength="20" name="nickname"><br /> <br />
    <INPUT TYPE="radio" NAME="status" checked onclick="document.all.AnonymousNo.style.visibility='hidden'"><b>Anonymous</b>
    <INPUT TYPE="radio" NAME="status" onclick="document.all.AnonymousNo.style.visibility='visible'"><b>Registered</b>
    <br /><br />
    <SPAN ID="AnonymousNo" >
    <b>Username</b><br />
    <INPUT TYPE="text" NAME="login" VALUE="" SIZE="25" MAXLENGTH="20">
    </SPAN>
    <b>Password</b><br />
    <input type="text" size="25" maxlength="20" name="pass"><br /> 
    <input type="submit" value="Connect">
    </form>
    </table>
    </body>
    I am wondering what I am doing wrong with the action of the form? The link doesnt load like it should. U can test this script at THIS LINK

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    I don't think the form action should have an echo in it. The action should be to the php page that processes the form. Google php forms for examples.
    Leonard Whistler

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    first you initialize this variable...
    PHP Code:
    <?php 
    $nickname 
    '';
    $status '';
    $pass '';
    $login '';
    ?>
    and then action become something like this:
    Code:
    teamspeak://ts3.gameservers.com:8786?nickname=?loginname=?password=
    I don't know if could work with all this variables as '', but I guess that one problem is that you have more then one '?'

    best regards

  • #4
    New Coder
    Join Date
    Feb 2008
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Ok i have added a new page now andi get it to go to the new page but how can i get the variables from the last page over to the new page and then redirect the page to a new destination

    PHP Code:
    <?php 

    $base 
    'teamspeak://ts3.gameservers.com:8786?nickname=';
    $loginad '?loginname=';
    $passad '?password=';
    $url $base $nickname $loginad $login$passad $pass;


    ?>
    <html>
    <body>
    <?php header'Location: $url' ) ; ?>
    <input type="text" size="40" maxlength="100" value="<?php echo $url ?>">

    </body>

    </html>
    I only have the text box to see the output because it is working except for putting in the varibles $nickname, $login, and $pass into the url

    And then after inputing the variables i need it to go to $url

    Ideas?
    Last edited by Money88; 02-19-2008 at 10:07 PM.

  • #5
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    a url of this form "...?nickname=me?loginad=you" I don't thing is ok.
    I allready say I my previous post. You must have a single '?' and the
    query string pair-value must be separated by & or ;, usualy &.

    so, this become:

    PHP Code:
    <?php
    $base 
    'teamspeak://ts3.gameservers.com:8786?nickname=';
    $loginad '&loginname='// <-
    $passad '&password='// <-
    $url $base $nickname $loginad $login$passad $pass;
    ?>
    to get variables from request, i presume, if you use $_GET, you can do:

    PHP Code:
    <?php
    $nickname 
    $_GET['nickname'];
    $loginad $_GET['loginad'];
    $passad $_GET['passadd'];
    ?>
    another things:
    - outputing html and body before header, don't rise an error?
    - any output after header, have any sens? this thing work? I guess is not.

    All what I'm saying is based on usual protocols, I don't know how teamspeak work.

    best regards

  • Users who have thanked oesxyl for this post:

    Money88 (02-19-2008)

  • #6
    New Coder
    Join Date
    Feb 2008
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Ok let me try to explain a little better.
    and wonder wat else i am doing wrong

    Ok Teamspeak can be executed with a command such as the one below when it is put into your browser. (bolded below are where the variables need to go. everything else is part of the command)

    teamspeak://ts3.gameservers.com:8786?nickname=NicknameVarGoesHere?loginname=LoginVarGoesHere?password=PassVarGoesHere

    Then the below code is the first page that i want the user to input the variables. What i need the connect button to do is load that command like it is loading a page in the bar above and it will connect how it should to the teamspeak.

    PHP Code:
    <?php 
    $nickname 
    $_POST['nickname'];
    $status $_POST['status'];
    $pass $_POST['pass'];
    $login $_POST['login'];
    ?>

    <html> 
    <head> 
    <title>TS Connect (STILL WORKING ON)</title> 
    </head> 
    <body onLoad="document.all.AnonymousNo.style.visibility='hidden'"> 
    <table width="100%" height="100%">
    <tr>
    <td align="center" width="90%" bgcolor="FFFFFF" border="2" bordercolor="000000">

    <form name="f1" method="post" action="ts_connect2.php">

    <b>Nickname</b><br />
    <input type="text" size="25" maxlength="20" name="nickname"><br /> <br />
    <INPUT TYPE="radio" NAME="status" checked onclick="document.all.AnonymousNo.style.visibility='hidden'"><b>Anonymous</b>
    <INPUT TYPE="radio" NAME="status" onclick="document.all.AnonymousNo.style.visibility='visible'"><b>Registered</b>
    <br /><br />
    <SPAN ID="AnonymousNo" >
    <b>Username</b><br />
    <INPUT TYPE="text" NAME="login" VALUE="" SIZE="25" MAXLENGTH="20">
    </SPAN><br />
    <b>Password</b><br />
    <input type="text" size="25" maxlength="20" name="pass"><br /> 
    <input type="submit" value="Connect">
    </form>
    </table>

    </body>
    </html>
    The below code now is the ts_connect2.php file that is loaded on submission.

    PHP Code:
    <?php 

    $nickname 
    $_GET['nickname'];
    $loginad $_GET['login'];
    $passad $_GET['pass'];

    $base 'teamspeak://ts3.gameservers.com:8786?nickname=';
    $loginad '&loginname=';
    $passad '&password=';
    $url $base $nickname $loginad $login$passad $pass;

    ?>
    two things that i ran into is that it will not recieve the variables from the ts_connect.php page when i do the get command on the ts_connect2.php page. and the second problem is that I do not know how to redirect the page to the url like normal website link if you clicked it.

  • #7
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    You need only one file, ts_connect.php:

    PHP Code:
    <?php 
    if(isset($_POST) && !empty($_POST)){
      
    $nickname $_POST['nickname'];
      
    $status $_POST['status'];
      
    $pass $_POST['pass'];
      
    $login $_POST['login'];
      
    $base 'teamspeak://ts3.gameservers.com:8786?nickname=';
      
    $loginad '&loginname=';
      
    $passad '&password=';
      
    // do any checking you need here
      
    $url $base $nickname $loginad $login$passad $pass;
       
    header("Location: ".$url);
    }else{
       
    // this happend only at first request, after that all this values
       // are passed on each request and fill the fields in the form
       
    $nickname '';
       
    $status '';
       
    $pass '';
       
    $login '';
    }
    ?>
    // the content of ts_connect.php with this change:
    <form name="f1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    // any field take the value from previous request
    <input .... value="<?php echo $login?>"/>
    ...
    - on first request the form is field with the values from else branch.
    - if the values passed from POST are invalid the fields are filled with previous value
    - when the values are valid, header will redirect to your url.

    I hope this help.

    best regards
    Last edited by oesxyl; 02-20-2008 at 12:01 AM.

  • Users who have thanked oesxyl for this post:

    Money88 (02-20-2008)

  • #8
    New Coder
    Join Date
    Feb 2008
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    thank you so far you have been VERY helpfull and i feel we are getting close.
    The code below is my whole document. When ran it takes me to a page that says this page cannot be displayed.

    PHP Code:
    <?php 
    if(isset($_POST) && !empty($_POST)){
      
    $nickname $_POST['nickname'];
      
    $status $_POST['status'];
      
    $pass $_POST['pass'];
      
    $login $_POST['login'];
      
    $base 'teamspeak://ts3.gameservers.com:8786?nickname=';
      
    $loginad '&loginname=';
      
    $passad '&password=';
      
    // do any checking you need here
      
    $url $base $nickname $loginad $login$passad $pass;
       
    header("Location: ".$url);
    }else{
       
    // this happend only at first request, after that all this values
       // are passed on each request and fill the fields in the form
       
    $nickname '';
       
    $status '';
       
    $pass '';
       
    $login '';
    }
    ?>
    <html> 
    <head> 
    <title>TS Connect (STILL WORKING ON)</title> 
    </head> 
    <body onLoad="document.all.AnonymousNo.style.visibility='hidden'"> 
    <table width="100%" height="100%">
    <tr>
    <td align="center" width="90%" bgcolor="FFFFFF" border="2" bordercolor="000000">

    <form name="f1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

    <b>Nickname</b><br />
    <input type="text" value="<?php echo $nickname?>" size="25" maxlength="20" name="nickname"><br /> <br />
    <INPUT TYPE="radio" NAME="status" checked onclick="document.all.AnonymousNo.style.visibility='hidden'"><b>Anonymous</b>
    <INPUT TYPE="radio" NAME="status" onclick="document.all.AnonymousNo.style.visibility='visible'"><b>Registered</b>
    <br /><br />
    <SPAN ID="AnonymousNo" >
    <b>Username</b><br />
    <INPUT TYPE="text" NAME="login" value="<?php echo $login?>" SIZE="25" MAXLENGTH="20">
    </SPAN><br />
     <b> Password </b> <br />
    <input type="text" size="25" value=" <?php echo $pass?>" maxlength="20" name="pass"><br /> 
    <input type="submit" value="Connect">
    </form>
    </table>

    </body>
    </html>
    Well the other thing is that all fields should be empty at start while the only required field is nickname. Im not sure what I can do the code makes sense but Seems not to be working...

  • #9
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    try this:

    PHP Code:
    <?php 
    // this is a alternative, to make sure that all values are empty when start
    // you must be sure that all this values are filled with the values from
    // $_POST if $_POST exists and is not empty but checking fail
    // also in form you must use $status somehow
    $nickname '';
    $status '';
    $pass '';
    $login '';
    if(isset(
    $_POST) && !empty($_POST)){
      
    $nickname $_POST['nickname'];
      
    $status $_POST['status'];
      
    $pass $_POST['pass'];
      
    $login $_POST['login'];
      
    $base 'teamspeak://ts3.gameservers.com:8786?nickname=';
      
    $loginad '&loginname=';
      
    $passad '&password=';
      
    // do any checking you need here
      
    $url $base $nickname $loginad $login$passad $pass;
      
    // debug:
      
    print_r($_POST);
      print 
    $url;
      
    // you could comment next line until url is what you need
      
    header("Location: ".$url);
    }
    // debug pourpuse:
    print_r($_POST);
    ?>
    <html> 
    <head> 
    <title>TS Connect (STILL WORKING ON)</title> 
    </head> 
    <body onLoad="document.all.AnonymousNo.style.visibility='hidden'"> 
    <table width="100%" height="100%">
    <tr>
    <td align="center" width="90%" bgcolor="FFFFFF" border="2" bordercolor="000000">

    <form name="f1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

    <b>Nickname</b><br />
    <input type="text" value="<?php echo $nickname?>" size="25" maxlength="20" name="nickname"><br /> <br />
    <INPUT TYPE="radio" NAME="status" checked onclick="document.all.AnonymousNo.style.visibility='hidden'"><b>Anonymous</b>
    <INPUT TYPE="radio" NAME="status" onclick="document.all.AnonymousNo.style.visibility='visible'"><b>Registered</b>
    <br /><br />
    <SPAN ID="AnonymousNo" >
    <b>Username</b><br />
    <INPUT TYPE="text" NAME="login" value="<?php echo $login?>" SIZE="25" MAXLENGTH="20">
    </SPAN><br />
     <b> Password </b> <br />
    <input type="text" size="25" value=" <?php echo $pass?>" maxlength="20" name="pass"><br /> 
    <input type="submit" value="Connect">
    </form>
    </table>

    </body>
    </html>
    you say that it work if you write the url in browser address bar, so use use the valid value from browser address to check if the redirection work simulating a $_POST, just replace $nickname, ..., with this values.

    best regards
    Last edited by oesxyl; 02-20-2008 at 12:53 AM.

  • Users who have thanked oesxyl for this post:

    Money88 (02-20-2008)

  • #10
    New Coder
    Join Date
    Feb 2008
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank you so much only thing that doesnt work is redirection I get this error "Warning: Cannot modify header information - headers already sent by (output started at /home/god/public_html/ts_connect.php:21) in /home/god/public_html/ts_connect.php on line 24"

  • #11
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Money88 View Post
    Thank you so much only thing that doesnt work is redirection I get this error "Warning: Cannot modify header information - headers already sent by (output started at /home/god/public_html/ts_connect.php:21) in /home/god/public_html/ts_connect.php on line 24"
    look to see what so you print or echo before the header line and remove or comment it. If you don't modify the script, I guess this is the line with print_r and/or print $url before the header.

    sorry for the late answer.

    best regards

  • #12
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts
    Oesxyl, it looks a lot better if directly in HTML you just put <? ?> instead of writing out php. that way you don't end up reading (extra) code, just looks neater.

    Also, $_POST doesn't put anything in the URLS. $_GET does that.

  • #13
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Deacon Frost View Post
    Oesxyl, it looks a lot better if directly in HTML you just put <? ?> instead of writing out php. that way you don't end up reading (extra) code, just looks neater.
    is a matter of style and habbits, I like this way, works for me.

    Also, $_POST doesn't put anything in the URLS. $_GET does that.
    oops, good point, was $_GET on the begining of the thread,

    thank you, .

    @Money88: make the $_POST, $_GET, please.

    best regards

  • #14
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts
    True true, whatever works well and help you with the code .

  • #15
    New Coder
    Join Date
    Feb 2008
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    well i changed all the $_POST to $_GET and now it doesnt even work when outputting the debugging.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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