doubleflashstyle Posted December 22, 2007 Share Posted December 22, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/82784-using-a-variable-from-a-form-with-a-link-button/ Share on other sites More sharing options...
phpQuestioner Posted December 22, 2007 Share Posted December 22, 2007 <?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>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/82784-using-a-variable-from-a-form-with-a-link-button/#findComment-421051 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.