Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/191992-writing-data-into-a-database/
Share on other sites

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}");
}
?>

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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