form help

Started on the old forum in December 2010 · view the original in the archive · old links redirect here

22 replies · 1,040 views · started 15 years ago · 1 min read

5 participants
frostymarvelous Senior · 266 posts #22

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.

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

atef201080 Developer · 58 posts #23

i have created my code and its working now thanks forstymarvelous,kei_ki7 and something else

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close