I don't know what exactly what you want to do, cos the variables will most likely be trimmed. Moreover putting a space after username will most likely break the url.
form help
Collapse
X
-
you can not have a space in a url .... it is url encoded so %20 or %2520 is a space
you can usePHP Code:$user = urldecode ($user);
Last edited by something else; 24.12.10, 11:29.
Comment
-
Did you tried the code that I've edit from your post?
I think you can do that by getting first the value of $user then make a link
Like what I've posted at http://coding-talk.com/f14/form-help...html#post65596
Comment
-
if i am right, you need a code to check for a space after the username or else display a
users are private message.
this should work if that is what you need.
try putting in a username without the space after and also try with the username after.
it places the space after the username in the url.
if this is not it, please clarify.
PHP Code:<html>
<head>
<title>View Friends</title>
</head>
<body>
<?php
if (!isset($_POST['action'])){
echo <<<FORM
<form action="" method="post">
<label for="username">Username:</label><br />
<input type="text" id="username" name="user" maxlength="50" placeholder="Enter your username" /><br />
<label for="pg">Page:</label><br />
<input type="text" id="pg" name="page" maxlength="200" value="1" size="2" /><br />
<input type="submit" name="action" value="View">
FORM;
}
else
{
if (!empty($_POST['user']) && !empty($_POST['page']))
{
$diff= strlen($_POST['user']) - strlen(rtrim($_POST['user']));// i separated this from the original code
//which was in the if statement
//so you can choose if the space left or right
//of the username by using either rtrim or ltrim
//and also choose the number of spaces required
if ($diff == 1)echo "
<a href=\"http://mig33.com/midlet/member/view_friends.php?username=$_POST[user]&pagenum=$_POST[page]\">
View $_POST[user]'s Friends.</a><br />
<a href=\"p.php\">Back</a>";
else echo "Friends are private";
}
else echo "Username or Page cannot be blank!";
}
?>
</body>
</html>Perfection comes at a cost
I accept liberty!
Comment
Comment