Jump to content

return results on one page


w4seem

Recommended Posts

ok i guess theres a quick answer to this one hopefully,

i have a search field on a .php page.

i want to return the results on the same page i.e i dont want the action to point to test2.php but test.php which is were my search filed is sitting at the moment.

how do i do this?  8)

 

i got this on my first page:

 

<form method="post" action="test2.php">

Name: <input type="text" size="10" maxlength="40" name="name"> <br />

<input type="submit" value="Send">

</form>

 

and this on the second:

 

<?php

$name = $_POST['name'];

if ($name=="Friday")

  echo "Have a nice weekend!";

elseif ($name=="Saturday")

  echo "Tomorrow is Sunday!";

else

  echo "Please enter Friday or Saturday";

?>

 

thanks

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/46572-return-results-on-one-page/
Share on other sites

do i change:

 

<form method="post" action="test2.php">

 

and direct it to the same page and then have the hidden tag? does the hidden tag replace my submit tag or is it in additon to it?

 

could you explain the hidden tag a little please so i understand it better. ill google it also and see what i can find.

 

thanks

 

 

 

here you go

 

file test.php

<?php
$action = $_POST['action'];

if (isset($action) )
{
   $name = $_POST['name'];
  if ($name=="Friday")
  echo "Have a nice weekend!"; 
elseif ($name=="Saturday")
  echo "Tomorrow is Sunday!"; 
else
  echo "Please enter Friday or Saturday"; 
}

?>

<form method="post" >
Name: <input type="text" size="10" maxlength="40" name="name"> 

<input type="submit" value="Send"> 
<input type="hidden" name="action" value="submitted">
</form>

Archived

This topic is now archived and is closed to further replies.

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