Jump to content

Using a variable from a form with a Link button


doubleflashstyle

Recommended Posts

I'm new to PHP/HTML and basically want to have an address bar on my site that redirects to a link,which changes depending on what the user types, after he clicks on a button.

 

I was using an example and everything there works, but I don't understand how to get something new to work:

 

So I have a Form:

<INPUT TYPE = "Text" VALUE ="" NAME = "ComID" >

<INPUT Name = "Submit1" TYPE = "Submit" VALUE = "Submit" onClick="MM_goToURL('parent','http://www.IWANTMY_ComID_SITEHERE!!.com');return document.MM_returnValue" >

 

How can I get the "ComID" variable (what the user types) to work with the MM_goToURL redirect thing, so that the user enters the address and when he clicks on it, is redirected there?

 

how would I replace 'http://www.IWANTMY_ComID_SITEHERE!!.com'  with a variable ?

 

I also have a php part below to pick it up:

 

<?PHP

$ComID = $_POST['ComID'];

print($ComID);

?>

 

 

That gives a highlightable bit of text that is the link but I want to have it redirect after pressing the button..

 

 

 

And this is the goToURL() function:

<script language="JavaScript" type="text/JavaScript">

<!--

function MM_goToURL() { //v3.0

  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;

  for (i=0; i<(args.length-1); i+=2) eval(args+".location='"+args[i+1]+"'");

}

//-->

</script>

<?php

$id = $_GET['ComID'];

if ($id != NULL)
{
header("Location: http://www.iwantmy.com/page.php?CommID=$id");
exit;
}
else {
echo '<form method="get">
<input type="text" name="ComID">
<input type="submit" value="Submit">
</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.