Jump to content

Form action input


Sinikka

Recommended Posts

What I'm trying to do is make the url reflect what a user inputs into the form. In this case it's to go to specific pages in a gallery. So for instance if I put 5 in the box and hit go I want the url to reflect that (/usergallery.php?game=1&user=sinikka&pageon=5).

 

$totalpage = mysql_num_rows(mysql_query("SELECT * FROM usergallerys_items WHERE owner = '$find_owner[id]' AND game = '$game'"));
$totalpage = ceil($totalpage / 40);

if($pageon > $totalpage){
$pageon = $totalpage;
}
$lmin = $pageon * 40;
$lmin -= 40;

?>
<div align=center><a href=usergallery.php?game=<?echo($game)?>&user=<?echo($user)?>&pageon=<?echo($pageon!='$totalpage') ? $pageon-1 : '1';?>>  < Previous</a> Page <?=$pageon;?>
        of <?=$totalpage;?> <a href=usergallery.php?game=<?echo($game)?>&user=<?echo($user)?>&pageon=<?echo($pageon!=$totalpage) ? $pageon+1 : '1';?>>Next ></a></center><br>
<center><form action=usergallery.php?game=<?echo($game)?>&user=<?echo($user)?> method=post>
<input type=text name="pageon" size="3" style="border: solid 1px #000000; font-size: 8pt; font-family: Verdana;"/>
<input type="submit" value="Go" style="border: solid 1px #000000; font-size: 8pt; font-family: Verdana; background: #ffffff" /></form>
        </div><br>
<?

 

 

Code it needs, maybe not specifically this phase but similar. Goes after &user=<?echo($user)?> in the last cluster.

 

&pageon=<?echo($pageon)?>

 

When I try the above phrase it keeps the url properly but doesn't pull the page ever, it always leaves it on 1 no matter what number I input.

Link to comment
https://forums.phpfreaks.com/topic/177190-form-action-input/
Share on other sites

Change method to get, so

 

method=get

 

Or if you wanted to get clever with Javascript (Doesn't add anything)

 

<script type="text/javascript">
function Send(Form)
{
var Len = Form.length;
var URL = "SomeURL.php";

URL += "?";

for(var i = 0;i<Len;i++)
	{
	if(Form.elements[i].type == "submit")
		{
		continue;
		}

	URL += Form.elements[i].name + "=" + Form.elements[i].value + "&";
	}

var VAL = URL.length - 1;
URL = URL.substr(0, VAL);

document.location = URL;

return false;
}
</script>

<form onsubmit="Send(this); return false">
<input type="text" name="One">
<input type="text" name="Two">
<input type="submit" value="Submit" onclick="Send
(this.parentNode); return false;">
</form>

 

Link to comment
https://forums.phpfreaks.com/topic/177190-form-action-input/#findComment-934262
Share on other sites

Code it needs, maybe not specifically this phase but similar. Goes after &user=<?echo($user)?> in the last cluster.

 

&pageon=<?echo($pageon)?>

 

When I try the above phrase it keeps the url properly but doesn't pull the page ever, it always leaves it on 1 no matter what number I input.

 

At the top of your script did you have something like...

 

if(isset($_GET['pageon'])) {
  $pageon = $_GET['pageon'];
}

 

... to actually use the value that your persisting in the URL?

Link to comment
https://forums.phpfreaks.com/topic/177190-form-action-input/#findComment-934267
Share on other sites

No, I didn't not have that but when checking I found a snippet that I missed. I have this:

 

if(!$pageon){
$pageon = 1;
}

 

But even with adding in what you've suggested it's not making a difference.

 

 

Code it needs, maybe not specifically this phase but similar. Goes after &user=<?echo($user)?> in the last cluster.

 

&pageon=<?echo($pageon)?>

 

When I try the above phrase it keeps the url properly but doesn't pull the page ever, it always leaves it on 1 no matter what number I input.

 

At the top of your script did you have something like...

 

if(isset($_GET['pageon'])) {
  $pageon = $_GET['pageon'];
}

 

... to actually use the value that your persisting in the URL?

Link to comment
https://forums.phpfreaks.com/topic/177190-form-action-input/#findComment-934268
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.