Jump to content

[SOLVED] Linking button


Andy17

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.