Jump to content

[SOLVED] php, javascript, html forms


FireDrake

Recommended Posts

Hi, I've got a few forms with a href in it all on one page. When you click this href, you will go to the page with

method='GET'

. Later in the script, I use the

if (isset ($_GET['name'])). 

and the user will get the page he asked for. I want to ask how to get these href's to work without using forms. The form I have at this time is:

 

<html>
<head>
	<link rel="stylesheet" type="text/css" href="/css.css"/>
	<style type="text/css"> 
		form { 
			margin-top: -1em;
			margin: 0px; 
			padding: 0px; 
		} 
		input {
			margin: 0px; 
			padding: 0px; 
		} 
		input.hidden { 
			display: none; 
		}
	</style>
</head>
<body>
<div class="c" style="position:absolute">
		<form name="home" method="GET">
			<input type=hidden name=link value=home class=hidden>
			<A href="javascript: document.home.submit()">Home</A> |
		</form>	
		<form name="wedstrijden" method="GET">
			<input type=hidden name=link value=wedstrijden class=hidden>
			<A href="javascript: document.wedstrijden.submit()">Wedstrijden</A> |
		</form>
		<form name="stemmen" method="GET">
			<input type=hidden name=link value=stemmen class=hidden>
			<A href="javascript: document.stemmen.submit()">Stemmen</A>
		</form>
	</div>
<?php

if (isset ($_GET['home']))
	{
		echo "<br /><br />the Page here";
	}
if (isset ($_GET['wedstrijden']))
	{
		echo "<br /><br /> another page here";
	}
if (isset ($_GET['stemmen']))
	{
		echo "<br /><br /> another page here";
	}
else {
	echo "no page";
}
?>
</body>
</html>

 

I want the url linking to the right page in first place, and I don't want the forms with a break between each form. Because now all of my hrefs are horizontal instead of vertical next to each other.

Can anyone please help me? Im stuck with this script for hours now.

Link to comment
https://forums.phpfreaks.com/topic/76499-solved-php-javascript-html-forms/
Share on other sites

<html>
  <head>
    <link rel="stylesheet" type="text/css" href="/css.css"/>
      <style type="text/css"> 
        form { 
          margin-top: -1em;
          margin: 0px; 
          padding: 0px; 
        } 
        input {
          margin: 0px; 
          padding: 0px; 
        } 
          input.hidden { 
          display: none; 
        }
      </style>
    </head>
    <body>
      <div class="c" style="position:absolute">
        <a href="?link=home">Home</a>
        <a href="?link=wedstrijden">Wedstrijden</a>
        <a href="?link=stemmen">Stemmen</a>
      </div>
<?php

  if (isset($_GET['link'])) {
    switch ($_GET['link']) {
      case "home":
        echo "<br /><br />the Page here";
        break;
      case "wedstrijden":
        echo "<br /><br /> another page here";
        break;
      case "stemmen":
        echo "<br /><br /> another page here";
        break;
      default:
        echo "no page";
    }
  } else {
    echo "no page";
  }

?>
  </body>
</html>

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.