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. Quote Link to comment 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"]); Quote Link to comment 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. Quote Link to comment 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"]); Quote Link to comment 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. Quote Link to comment 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.. Quote Link to comment 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.. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.