Sinikka Posted October 10, 2009 Share Posted October 10, 2009 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 More sharing options...
Garethp Posted October 10, 2009 Share Posted October 10, 2009 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 More sharing options...
Sinikka Posted October 10, 2009 Author Share Posted October 10, 2009 I've tried that, it makes the url change to /usergallery.php?pageon=5 and leaves out the other info that is needed. Link to comment https://forums.phpfreaks.com/topic/177190-form-action-input/#findComment-934263 Share on other sites More sharing options...
Garethp Posted October 10, 2009 Share Posted October 10, 2009 I edited my previous post. Just edit the Javascript where it declares URL Link to comment https://forums.phpfreaks.com/topic/177190-form-action-input/#findComment-934266 Share on other sites More sharing options...
cags Posted October 10, 2009 Share Posted October 10, 2009 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 More sharing options...
Sinikka Posted October 10, 2009 Author Share Posted October 10, 2009 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 More sharing options...
eugene2009 Posted October 10, 2009 Share Posted October 10, 2009 Do you want this gallery to open up in a new window? Link to comment https://forums.phpfreaks.com/topic/177190-form-action-input/#findComment-934487 Share on other sites More sharing options...
pankajnagarkoti84 Posted October 10, 2009 Share Posted October 10, 2009 I edited my previous post. Just edit the Javascript where it declares URL Link to comment https://forums.phpfreaks.com/topic/177190-form-action-input/#findComment-934489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.