PDA

View Full Version : Form won't submit properly



Moh
19-06-2008, 01:37 PM
I am having a problem with a form, I am using method="GET", and I want it to do the following:

index.php?page=search&q=Search Term

But it keeps doing the following:
index.php?q=Search Term

The only way I got this working was using javascript, but onsubmit wouldn't work, only onclick. So if you press enter, it goes to:
index.php?q=Search Term

+Rep for any help :)

Invent
19-06-2008, 02:01 PM
Try adding:



<input type="hidden" name="page" id="page" value="search" />


with the GET method.

Moh
19-06-2008, 02:12 PM
Try adding:



<input type="hidden" name="page" id="page" value="search" />
with the GET method.
That's cheating :P
But it will do :P

Thank You :)

Blob
20-06-2008, 01:46 PM
action="index.php?page=search"

?

Independent
20-06-2008, 03:13 PM
action="index.php?page=search"

?
Don't you know how to use get? :P

Decode
20-06-2008, 04:10 PM
Don't you know how to use get? :P
Lol, i think he does.

Blob
22-06-2008, 10:32 AM
Don't you know how to use get? :P

Sorry, but sending a page to index.php?page=search will add all the form things after that, making the end URL end up as index.php?page=search&q=WHATEVER

fool.

Independent
22-06-2008, 01:56 PM
Sorry, but sending a page to index.php?page=search will add all the form things after that, making the end URL end up as index.php?page=search&q=WHATEVER

fool.
So basically, you want it sent to page.php?page=search without anything else in the URL bar,

I'd do it some long way like sessions.

Independent
22-06-2008, 02:12 PM
So basically, you want it sent to page.php?page=search without anything else in the URL bar,

I'd do it some long way like sessions.
Couldn't edit above post



<?php
session_start();

if(!$_GET ['page'] == "search") {
echo("<form method=\"post\" action=\"roflcopter.php?page=search\">
<input name=\"whatisit\">
<input type=\"submit\" value=\"Search!\">
</form><br /><br />\"IM FEELING LUCKY\"");
}
if($_GET ['page'] == "search") {

$go = $_POST['whatisit'];

$_SESSION['search'] = $go;

echo $_SESSION['search'];
}
?>
Un-tidy code I know.. but something along them lines :D
Wooohoo, I made something that works. :D

Independent
22-06-2008, 02:57 PM
Offtopic (ish):



<?php
session_start();

if(!$_GET ['page'] == "search") {
echo("<img src=\"images/webLOL.bmp\"><center><br /><br /><img src=\"http://www.google.co.uk/intl/en_uk/images/logo.gif\"><form method=\"post\" action=\"roflcopter.php?page=search\">
<br /><input name=\"whatisit\">
<input type=\"submit\" value=\"Search!\">
</form><br /><br />");
}
if($_GET ['page'] == "search") {

$go = stripslashes( $_POST['whatisit'] );

$_SESSION['search'] = $go;

echo "
<img src=http://www.calonuk.net/images/webLOL.bmp><br />&nbsp;<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"158\"><img src=http://www.calonuk.net/images/lolgle.bmp></td>
<td><input value=\"". $_SESSION['search'] ."\"></td>
</tr>
<tr>
<td height=\"55\" colspan=\"2\" align=\"left\" valign=\"top\"><font face=\"Trebuchet MS\" size=\"3\">We could not find
any results for ". $_SESSION['search'] ."</td>
</tr>
</table>";
}
?>

I made that cause' I was bored :P

Hope it comes in handy

ontopic: Hope the other code comes in handy.

Decode
22-06-2008, 02:58 PM
Couldn't edit above post



<?php
session_start();

if(!$_GET ['page'] == "search") {
echo("<form method=\"post\" action=\"roflcopter.php?page=search\">
<input name=\"whatisit\">
<input type=\"submit\" value=\"Search!\">
</form><br /><br />\"IM FEELING LUCKY\"");
}
if($_GET ['page'] == "search") {

$go = $_POST['whatisit'];

$_SESSION['search'] = $go;

echo $_SESSION['search'];
}
?>
Un-tidy code I know.. but something along them lines :D
Wooohoo, I made something that works. :D
Or you could do;

<form action="hi.php" method="get">
<input type="hidden" value="search" name="page">
<input type="text" name="search">
<input type="submit" value="Search">
</form>

Independent
22-06-2008, 02:59 PM
Or you could do;

<form action="hi.php" method="get">
<input type="hidden" value="search" name="page">
<input type="text" name="search">
<input type="submit" value="Search">
</form>
or is a bore.

My code fully works, so if you wanna save time use mine :8

Dentafrice
22-06-2008, 03:02 PM
Thats not really saving time, thats taking up more code space when you could just easily use a hidden field.. I would rather have one line of HTML code then 65654654651 useless lines of PHP clogging up my workspace.

Independent
22-06-2008, 04:52 PM
Thats not really saving time, thats taking up more code space when you could just easily use a hidden field.. I would rather have one line of HTML code then 65654654651 useless lines of PHP clogging up my workspace.
Fair enough

Want to hide these adverts? Register an account for free!