cip6791 Posted February 13, 2010 Share Posted February 13, 2010 Hello, I would like to write whatever is being typed into this form: <form class="form" target="_blank" action="<?=$_SERVER['REQUEST_URI']?>" method="post"> <img src="images/digg-big.jpg" alt="digg" border="0" style="padding-bottom:10px;" align="absmiddle"></img> <select name="site" id="site" class="site"> <? foreach($sites as $key=>$site){?> <option value="<?=$key?>"><?=$key?></option> <?}?> </select> <input type="text" name="page" class="input" /> <input type="submit" name="submit" class="go" value="Go" /> </form> into a database. I know that i'm suppose to create a new page ... update.php ... and action ="update.php" but what do I do with the action="<?=$_SERVER['REQUEST_URI']?>" ? Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/191992-writing-data-into-a-database/ Share on other sites More sharing options...
trq Posted February 13, 2010 Share Posted February 13, 2010 but what do I do with the action="<?=$_SERVER['REQUEST_URI']?>" ? The forms action needs to point to your processing script. You said this yourself. Quote Link to comment https://forums.phpfreaks.com/topic/191992-writing-data-into-a-database/#findComment-1011957 Share on other sites More sharing options...
cip6791 Posted February 13, 2010 Author Share Posted February 13, 2010 This is the rest of the code that I am using. Will this still work if I change the action to the processing script? <?php $sites = array(); $sites['Example.com'] = "http://www.example.com/pages/%u"; if(isset($_POST['submit']) && !empty($_POST['page']) && !empty($sites[$_POST['site']])){ $url = str_replace('%u',$_POST['page'],$sites[$_POST['site']]); header("Location: {$url}"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/191992-writing-data-into-a-database/#findComment-1011963 Share on other sites More sharing options...
trq Posted February 13, 2010 Share Posted February 13, 2010 I don't see how that code relates to your question. Quote Link to comment https://forums.phpfreaks.com/topic/191992-writing-data-into-a-database/#findComment-1011964 Share on other sites More sharing options...
cip6791 Posted February 13, 2010 Author Share Posted February 13, 2010 Well the way it works is ... It opens up a new tab in a browser with http://www.example.com/nokia.html let s say. I would just like to be able to fill in nokia with anything i want. I didn't write the script ... so maybe that s why it s a little confusing. I'm new at this. It' like this: <?php $sites = array(); $sites['example'] = "http://www.example.com/%u"; if(isset($_POST['submit']) && !empty($_POST['page']) && !empty($sites[$_POST['site']])){ $url = str_replace('%u',$_POST['page'],$sites[$_POST['site']]); header("Location: {$url}"); } ?> <html> <body> <form target="_blank" action="<?=$_SERVER['REQUEST_URI']?>" method="POST"> <select name="site" id="site"> <? foreach($sites as $key=>$site){?> <option value="<?=$key?>"><?=$key?></option> <?}?> </select> <input type="text" name="page" /> <input type="submit" name="submit" value="Go" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/191992-writing-data-into-a-database/#findComment-1011967 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.