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
atef201080 Developer · 58 posts #1

i want to make a form add a space behind the username iam using

username:

<form action="http://www.mig33.com/midlet/member/view_friends.php"> <input name="username" hidden value=" ">

page number: <input name="pagenum">

<input type="submit" value="find Friends"> </form>

but it going to link http://www.mig33.com/midlet/member/view_friends.php?username=atef&pagenum=1 i want to add aumaticly space after atef like that link http://www.mig33.com/midlet/member/view_friends.php?username=atef &pagenum=1

atef201080 Developer · 58 posts #2

i have created that

1.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Friends Viewer</title> </head> <body> <form method="post" action="vf.php">

Username:

<input type="text" name="user" size="35" />

Page:

<input type="text" name="page" size="35" /> <input type="submit" value="View" /> </form> </body> </html>

and vf.php

<?php $user = $_POST['user']; $page = $_POST['page']; ?> <?php echo ' '; print "<a href=\"http://www.mig33.com/midlet/member/view_friends.php?username=$user &pagenum=$page\">Viewe $user Friends</a> "; ?>

but it dosnt working at mobile browser please any1 help

frostymarvelous Senior · 266 posts #3

I don't know what you mean by you want a space.

Btw. You made a form and did not even specify if it was to send data using the get or post method, and you tried using post.

Instead of $_POST, try using $_GET.

Perfection comes at a cost

I accept liberty!

something else Fellow · 2,296 posts #5
$username = ' '.$_POST['username']; //space before username
frostymarvelous Senior · 266 posts #6

I just rEread both posts. CAn you specify which one you need help with? and exactly what?

the seCond one is perfect, but your first post lacks in many aspects. you need to first of all correct the form to be standard html. mobile browsers are limited in correcting malformed html.

Perfection comes at a cost

I accept liberty!

atef201080 Developer · 58 posts #7

thanks for all who help i am created it now and its totaly working 🙂 now how to make the 2 pages at 1 php page like the auto index who working by 1 page

frostymarvelous Senior · 266 posts #9

now how to make the 2 pages at 1 php page

What does that mean?

Perfection comes at a cost

I accept liberty!

ionutvmi Junior · 45 posts #10

just use if()

<?php
$action=$_GET['action'];
if(!$action) {
// do something
} else {
// do something else 
}
?>

to show something else you need to have page.php?action=aaa If you use page.php it will show something...

PIMP-WAP.NET - PIMP YOUR MOBILE

MASTER-LAND.NET - WAPMASTERS LAND

atef201080 Developer · 58 posts #11

i have created that

<?php
echo '<html>';
echo '<head>';
echo '<title>View Friends</title>';
echo '</head>';
echo '<body>';

    echo '<form action="p.php?action=view" method="post">';
   echo 'Username:<br><input name="user" maxlength="50" /><br>';
   echo 'Page:<br><input name="page" maxlength="200" value="1" /><br>';
   echo '<input type="submit" value="View">';
   echo '</form>';

echo '</body></html>';

if($_GET['action']=='view')
{
$user=$_GET['user'];
$page=$_GET['page'];
print "<a href=\"http://www.mig33.com/midlet/member/view_friends.php?username=.$user. &pagenum=.$page."\">Viewe .$user. Friends</a><br/>";
} 
?>

but it not working

Added after 3 minutes:

frostymarvelous i want to make the html form and php code at same page like that code i posted

frostymarvelous Senior · 266 posts #12

Hope this helps

<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'])) 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 "Username or Page cannot be blank!";
}
?>
</body>
</html>

Perfection comes at a cost

I accept liberty!

kei_ki7 Senior · 431 posts #13
<?php echo '<html>'; echo '<head>'; echo '<title>View Friends</title>'; echo '</head>'; echo '<body>'; echo '<form action="p.php?action=view" method="post">'; echo 'Username: <input name="user" maxlength="50" /> '; echo 'Page: <input name="page" maxlength="200" value="1" /> '; echo '<input type="submit" value="View">'; echo '</form>'; echo '</body></html>'; if($_GET['action']=='view') { $user=$_GET['user']; $page=$_GET['page']; print "<a href=\"http://www.mig33.com/midlet/member/view_friends.php?username=.$user. &pagenum=.$page."\">Viewe .$user. Friends</a> "; } ?>

The quote in red is the error

Added after 11 minutes:

Try this, Im not sure if that is what you want.

<?php
echo '<html>';
echo '<head>';
echo '<title>View Friends</title>';
echo '</head>';
echo '<body>';

   echo '<form action="p.php" method="get">';
   echo 'Username:<br><input name="user" maxlength="50" /><br>';
   echo 'Page:<br><input name="page" maxlength="200" value="1" /><br>';
   echo '<input name="action" type="hidden" value="view" /><br>';
   echo '<input type="submit" value="View">';
   echo '</form>';

echo '</body></html>';

if($_GET['action']=='view')
{
$user=$_GET['user'];
$page=$_GET['page'];
print "<a href=\"http://www.mig33.com/midlet/member/view_friends.php?username=$user &pagenum=$page\">Viewe $user Friends</a><br/>";
} 
?>

Did I help you? You can help me too Your donations will help me finance my studies.

something else Fellow · 2,296 posts #15

why would you want a space after then name in the url when you can easily create one on the page its directed to eg:

$user = $_GET['user'].' '; //space after username 
frostymarvelous Senior · 266 posts #16

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.

Perfection comes at a cost

I accept liberty!

atef201080 Developer · 58 posts #17

it will not break the url i have tryed by somthing else code but it showing %2520 at the url but i want a space not %2520

something else Fellow · 2,296 posts #18

you can not have a space in a url .... it is url encoded so %20 or %2520 is a space

you can use

$user = urldecode ($user); 

To decode the encoded url

frostymarvelous Senior · 266 posts #19

The url is automatically decoded upon receipt.

Thing is, if the space is after username, then it is before = which should break the url.

Perfection comes at a cost

I accept liberty!

atef201080 Developer · 58 posts #20

i have try that $user = $_POST['user']; $user = urldecode ($user ); but it dosnt work @forstymarvelous showing friends a trick if the link entered without space will show the friends marked as private but if there a space after the username will show the friends, get it ?

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