Andy17 Posted October 14, 2008 Share Posted October 14, 2008 Hey guys, I have a small problem; I am trying to send a button on to a new page with the code below. However, my URL parameter (page=1) does not work; it sends me to "adult.php?" and completely leaves out the last part of the URL. Is it possible to use parameters this way? If so, how should I go about it? If not, does anyone have any suggestions on what else to do (still using a button)? <FORM METHOD="LINK" ACTION="adult.php?page=1"> <INPUT TYPE="submit" VALUE="Button name"> </FORM> Thank you for your help. EDIT: I just realized that this is not in the correct category. However, I cannot delete the topic, so any moderator is more than welcome to move this. My apologies. Link to comment https://forums.phpfreaks.com/topic/128347-solved-linking-button/ Share on other sites More sharing options...
GKWelding Posted October 14, 2008 Share Posted October 14, 2008 Change your form to this... <FORM METHOD="POST" ACTION="adult.php"> <INPUT TYPE="hidden" NAME="page" VALUE="1"> <INPUT TYPE="submit" VALUE="Button name"> </FORM> Then in your page.php have your page variable set to retrieve the POST value of page. $page=mysql_real_escape_string($_POST["page"]); Link to comment https://forums.phpfreaks.com/topic/128347-solved-linking-button/#findComment-664855 Share on other sites More sharing options...
thebadbad Posted October 14, 2008 Share Posted October 14, 2008 Or simply use method="get" (in GKWelding's example), if you want the "?page=1" to be attached to the URL. Link to comment https://forums.phpfreaks.com/topic/128347-solved-linking-button/#findComment-664856 Share on other sites More sharing options...
GKWelding Posted October 14, 2008 Share Posted October 14, 2008 If you do use the GET function then don't forget to change $page=mysql_real_escape_string($_POST["page"]); to $page=mysql_real_escape_string($_GET["page"]); Link to comment https://forums.phpfreaks.com/topic/128347-solved-linking-button/#findComment-664857 Share on other sites More sharing options...
Andy17 Posted October 14, 2008 Author Share Posted October 14, 2008 Thanks guys. Just one problem now. I get this error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 20' at line 1 when I do this: $number = mysql_real_escape_string($_GET["page"]); But it works if I do this (with no mysql escape string): $number = $_GET['page']; I don't have anything on line 1 (only <?php, and the next few lines don't have anything with "20" in them). Any ideas? Thank you. Link to comment https://forums.phpfreaks.com/topic/128347-solved-linking-button/#findComment-664859 Share on other sites More sharing options...
monkeytooth Posted October 14, 2008 Share Posted October 14, 2008 If your just using a button as a button but not a form.. why not do an OnClick event? <INPUT TYPE="BUTTON" VALUE="Home Page" ONCLICK="window.location.href='http://www.phpfreaks.com/forums/index.php"> Set the URL if dynamic into a variable via PHP and then echo the var as opposed to the static URL.. Link to comment https://forums.phpfreaks.com/topic/128347-solved-linking-button/#findComment-664860 Share on other sites More sharing options...
monkeytooth Posted October 14, 2008 Share Posted October 14, 2008 Show your whole code, edit it to remove any passwords or what ever for the SQL entries.. but show the whole thing.. "20" might be an output, might be something else from else where.. could be a missing bracket, unneeded double quote, or single quote.. or the need of.. number of things.. Link to comment https://forums.phpfreaks.com/topic/128347-solved-linking-button/#findComment-664863 Share on other sites More sharing options...
Andy17 Posted October 14, 2008 Author Share Posted October 14, 2008 Never mind, I fixed it. Thank you for the help, guys! I appreciate it. Link to comment https://forums.phpfreaks.com/topic/128347-solved-linking-button/#findComment-664864 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.