...

View Full Version : Link help



Money88
02-19-2008, 09:06 PM
<?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 (http://mwgclan.com/ts_connect.php)

Len Whistler
02-19-2008, 09:16 PM
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.

oesxyl
02-19-2008, 09:26 PM
first you initialize this variable...


<?php
$nickname = '';
$status = '';
$pass = '';
$login = '';
?>


and then action become something like this:


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

Money88
02-19-2008, 10:00 PM
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

$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?

oesxyl
02-19-2008, 10:32 PM
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
$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
$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

Money88
02-19-2008, 11:20 PM
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=PassVarGoe sHere

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
$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

$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.

oesxyl
02-19-2008, 11:58 PM
You need only one file, ts_connect.php:



<?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

Money88
02-20-2008, 12:20 AM
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
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...

oesxyl
02-20-2008, 12:49 AM
try this:


<?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&#37;" 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

Money88
02-20-2008, 03:01 AM
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"

oesxyl
02-20-2008, 07:17 AM
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

Deacon Frost
02-20-2008, 07:27 AM
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.

oesxyl
02-20-2008, 07:50 AM
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

Deacon Frost
02-20-2008, 08:03 AM
True true, whatever works well and help you with the code :D.

Money88
02-20-2008, 07:39 PM
well i changed all the $_POST to $_GET and now it doesnt even work when outputting the debugging.

rafiki
02-20-2008, 07:43 PM
change all $var = $_POST['var']; to $var = $_GET['var'];

oesxyl
02-20-2008, 09:07 PM
well i changed all the $_POST to $_GET and now it doesnt even work when outputting the debugging.

sorry, I miss one thing, you must also change, method in form element from POST to GET.

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum